Error 3075 - cant find the solution to why i get this error

behedwin

Active Member
Joined
Dec 10, 2014
Messages
399
Hi

My database launches SelecProfile_Form when it starts.
Then i run this code

Code:
Application.Echo False

If Form_SelectProfile_Form.Dirty Then Form_SelectProfile_Form.Dirty = False
If Not IsNull(Form_SelectProfile_Form.txtProfile_ID) Then
DoCmd.OpenForm "Profile_Form", , , "Profile_ID = " & Form_SelectProfile_Form.ListPicker
End If

If Me.Dirty Then Me.Dirty = True
DoCmd.Close acForm, Me.Name

ProfileEffects_Read

Application.Echo True
When double clicking on a listbox row.

Then my profile_form opens

Then i run this code
Code:
Private Sub TjanstFordelning_Button_Click()
Application.Echo False


If Me.Dirty Then Me.Dirty = False
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "UndervisningsTid_Form"
Form_SelectProfile_Form.ListPicker.Requery

Application.Echo True
End Sub
and directly this code
Code:
Private Sub txtCloseSave_Button_Click()
Application.Echo False


If Me.Dirty Then Me.Dirty = True
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Profile_Form"
Forms!Profile_Form.Requery


Application.Echo True
End Sub
and this code
Code:
Private Sub Close_button_Click()
Application.Echo False

If Me.Dirty Then Me.Dirty = False
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "SelectProfile_Form"
Form_SelectProfile_Form.ListPicker.Requery

Application.Echo True
End Sub

then i run the first code again (double click the listbox)
and i get this error message

screenshot: http://prntscr.com/he4jkc
Error 3075 SYNTAXERROR on profile_id
If i go to the code, excel highligths this row

Code:
Private Sub ListPicker_DblClick(Cancel As Integer)
Application.Echo False

If Form_SelectProfile_Form.Dirty Then Form_SelectProfile_Form.Dirty = False
If Not IsNull(Form_SelectProfile_Form.txtProfile_ID) Then
[I][B]DoCmd.OpenForm "Profile_Form", , , "Profile_ID = " & Form_SelectProfile_Form.ListPicker[/B][/I]
End If

If Me.Dirty Then Me.Dirty = True
DoCmd.Close acForm, Me.Name

ProfileEffects_Read

Application.Echo True
End Sub

i only get this error if i go from form selectprofile_form opens a profile to profile_form
go the button that opens undervisningstid_form
close that form and then close profile_form
and try to open the profile again.

if i skip opening undervisningstid_form i do not get this error atall.



Please help me find the error so i can correct it.
If you want my project file, let me know and ill upload it.
 
What is the value of ListPicker.ListIndex when you get the error?

If it's not -1 you might be able to use it to get the selected value from ListPicker.

Something like this perhaps.
Code:
With Form_SelectProfile_Form.ListPicker
    DoCmd.OpenForm "Profile_Form", , , "Profile_ID = " & .List(.ListIndex
End With
 
Upvote 0

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
What is the value of ListPicker.ListIndex when you get the error?

If it's not -1 you might be able to use it to get the selected value from ListPicker.

Something like this perhaps.
Rich (BB code):
With Form_SelectProfile_Form.ListPicker
    DoCmd.OpenForm "Profile_Form", , , "Profile_ID = " & .List(.ListIndex
End With

When the error occurs
i did what you said before ctrl+g and use

? Form_SelectProfile_Form.ListPicker.value

Then the result is "Null"


I updated the code to this (with your suggestion)

Code:
Private Sub ListPicker_DblClick(Cancel As Integer)
Application.Echo False

If Form_SelectProfile_Form.Dirty Then Form_SelectProfile_Form.Dirty = False
If Not IsNull(Form_SelectProfile_Form.txtProfile_ID) Then
If ListPicker.ListIndex = -1 Then
Exit Sub
Else
[B]With Form_SelectProfile_Form.ListPicker
    DoCmd.OpenForm "Profile_Form", , , "Profile_ID = " & .List(.ListIndex
End With[/B]
'DoCmd.OpenForm "Profile_Form", , , "Profile_ID = " & Form_SelectProfile_Form.ListPicker
End If
End If

If Me.Dirty Then Me.Dirty = True
DoCmd.Close acForm, Me.Name

ProfileEffects_Read

Application.Echo True
End Sub

This does not work atall
I cant double click at any time.

I get this error
http://prntscr.com/hee36v (screenshot)

if i run the immediate directly after this error
i get the result that is "24"
that is the correct value.
screenshot: http://prntscr.com/hee45f (screenshot)
 
Upvote 0
There's a missing closing ).
Code:
With Form_SelectProfile_Form.ListPicker
    DoCmd.OpenForm "Profile_Form", , , "Profile_ID = " & .List(.ListIndex)
End With
 
Upvote 0
Forgot it was Access, perhaps.
Code:
With Form_SelectProfile_Form.ListPicker
    DoCmd.OpenForm "Profile_Form", , , "Profile_ID = " & .ItemData(.ListIndex)
End With
 
Upvote 0
Forgot it was Access, perhaps.
Code:
With Form_SelectProfile_Form.ListPicker
    DoCmd.OpenForm "Profile_Form", , , "Profile_ID = " & .ItemData(.ListIndex)
End With

That worked.
However the same orginal problem is still there
http://prntscr.com/heerz3 (screenshot)
http://prntscr.com/heesmj (screenshot)

and the value still thinks it is null.


here is my file uploaded.
download here: https://ufile.io/0v7ad

If you open, then go to:
1. Open SelectProfile_Form
2. DoubleClick on a row in the big listbox
3. Profiles opens
4. Click on "ÖPPNA TJÄNSTEFÖRDELNING" (at the top of the profile_form window)
5. New form is opening
6. Click "SPARA & STÄNG" at the top right corner of the new form.
7. Form will close
8. Click "SPARA & STÄNG" in Profile_Form form.
9. Form will close
10. Doubleclick on a row in listbox in SelectProfile_Form
11. Error should now appear
 
Upvote 0
You say what I posted worked but you are still having the same problem.:eek:
 
Upvote 0
Try this.
Code:
With ListPicker
    DoCmd.OpenForm "Profile_Form", , , "Profile_ID = " & .ItemData(.ListIndex)
End With
 
Upvote 0
You say what I posted worked but you are still having the same problem.:eek:

Yes sorry, bit unclear. I meant that the code without the ending that you posted now worked... but the original topic error still was left.

Try this.
Code:
With ListPicker
    DoCmd.OpenForm "Profile_Form", , , "Profile_ID = " & .ItemData(.ListIndex)
End With


This worked very well.
I can not recreate the error now.
Thank you very much for this!!

Can you see a reason for the error and what your solution fixed... why was my code wrong and yours correct?
 
Upvote 0
To be honest I can't see why that work.

I do know that you don't need to use the form name to refer to controls on the form if the code is in the form's module, you can either omit it or use Me.
 
Upvote 0

Forum statistics

Threads
1,215,024
Messages
6,122,729
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top