Hello there!
I run this code under a command button on my Main Menu to find the first record based on criteria in the form that I want to open:
The code works fine if it finds the current user in the records. If it doesn't find anything, I get an error.
How can I fix this error?
I've tried something with NoMatch syntax, but I couldn't achieve much.
Please help!
Thx!
I run this code under a command button on my Main Menu to find the first record based on criteria in the form that I want to open:
Code:
Private Sub Command0_Click()
If TempVars("CurrentUser") = "admin" Then
DoCmd.OpenForm "Events"
Else
DoCmd.OpenForm "Events"
Forms("Events").Recordset.FindFirst "Event =" & DLookup("IDevent", "tblEvents", _
"IDevent=" & "IDevent" & " And [UserName] = '" & TempVars("CurrentUser") & "'")
[COLOR=#ff0000][B][I]'something to add in here[/I][/B][/COLOR]
End If
End Sub
The code works fine if it finds the current user in the records. If it doesn't find anything, I get an error.
How can I fix this error?
I've tried something with NoMatch syntax, but I couldn't achieve much.
Please help!
Thx!
Last edited: