I have a query that has a parameter input to enter a customer ID.
There is a form that references this query.
In the form on the On Activate code for vba I am trying to show a message if the user inputs
a record number that does not exist with a message "No Record found"
My code in the On Activate event procedure for the form is this:
Private Sub Form_Activate()
If DCount("*", "FindID#") = 0 Then
MsgBox "No record"
Else
DoCmd.OpenForm (FindID#)
End If
End Sub
When I run the form and enter a record known not to exist I get this:
Run-time error '2471':
The expressions you entered as a query parameter produced this error:
'[Enter ID #]'
The above is the parameter that opens when you run the query.
The query works fine. If I enter a known non existent number in the query
it shows a window with no record.
Where in my coding am I wrong? Do I not have it in the proper event procedure?
Or is the code I have entered just wrong?