Run time error 3075 fix

Infinite

More left to learn.
Local time
Yesterday, 19:59
Joined
Mar 16, 2015
Messages
402
Hello! I have a list box, and if the user doesnt select a show and double clicks on the top of the list box, then it gives the whole

Code:
Run-time error '3075':
Syntax error (missing operator) in query expression 'EventID = '.

Now, what I would like to know is there any way to block that error? Change it to a text box to say something? Or anything like that? Thanks!
 
I would test for a selection before proceeding:

Code:
If Me.lstEmployees.ItemsSelected.Count = 0 Then
  MsgBox "Must select at least 1 employee"
  Exit Sub
End If
 
Okay, that does work, but it still gives the error.
 
What is your code? It should only continue with your process if it passes this test.
 
Code:
Private Sub lstShows_DblClick(Cancel As Integer)

If Me.lstShows.ItemsSelected.Count > 0 Then
MsgBox "Select a show please"

End If

If Me.Check30 = -1 Then
DoCmd.OpenForm "frmEventsEdit1", , , "EventID = " & Me.lstShows '.Column(0)
Else
DoCmd.OpenForm "frmEventsEdit", , , "EventID = " & Me.lstShows ' .Column(0)


End If
End Sub

That is it.
 
You dropped this from my suggestion:

Exit Sub
 
I added that but its not doing anything, just erroring, showing the message box, and not opening it.
 
What's the code now?
 
Code:
Private Sub lstShows_DblClick(Cancel As Integer)

If Me.lstShows.ItemsSelected.Count > 0 Then
MsgBox "Select a show please"
  Exit Sub
End If

If Me.Check30 = -1 Then
DoCmd.OpenForm "frmEventsEdit1", , , "EventID = " & Me.lstShows '.Column(0)
Else
DoCmd.OpenForm "frmEventsEdit", , , "EventID = " & Me.lstShows ' .Column(0)


End If
End Sub
 
Oh, and I tested for "=" 0, you've changed it to ">".
 

Users who are viewing this thread

Back
Top Bottom