Shola has attended:
Access Introduction course
Access Intermediate course
Access Advanced course
Excel Intermediate course
Excel Advanced course
Excel VBA Intro Intermediate course
Excel Advanced course
Attaching a msgbox/macro to a parameter
Is it possible to attach a msgbox to a parameter?
I have created a parameter in a query and the query is linked to a form. It is a date parameter. However it still aloows the user to enter an invalid date e.g. 31/04/07. I would like to attach a macro to the parameter to prevent the user from entering such invalid dates, using msgboxs and macro control-actions
RE: Attaching a msgbox/macro to a parameter
Shola
To Verify the value of an entry before running the query do the following:
Create a form with a text box (For the date) And a Command Button
In the command button On Click command write code along these lines:
Private Sub cmdOK_Click()
If IsDate(txtDate.Value) = False Then
MsgBox "Please enter correct Date"
txtDate.SetFocus
Exit Sub
End If
DoCmd.OpenQuery "My Query"
End Sub
Then in the Query, in the criteria line for the date, use Build to set the query to look at txtDate on the form for the required value.
Regards
Carlos