Formerly Best Training
© 2024 STL. All Rights Reserved.
All prices offered for business users and exclude VAT. E&OE
2nd Floor, CA House, 1 Northey Street, Limehouse Basin, London, E14 8BT. United Kingdom
Forum home » Delegate support and help forum » Microsoft Access Training and help » microsoft+access+course - Attaching a msgbox/macro to a parameter
Resolved · Low Priority · Version Standard
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
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
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
|
Access tip:Combo box for finding recordsYou can use a combo box in a form to look up a record. If you place the comb box in the Form header, by then selcting they a field type from the drop down loist, you will see the record for it |
We'll call during UK business hours
Server loaded in 0.08 secs.