microsoft+access+course - attaching msgboxmacro parameter

TrustPilot

starstarstarstarstar Excellent

  • Home
  • Courses
  • Promotions
  • Schedule
  • Formats
  • Our Clients

Forum home » Delegate support and help forum » Microsoft Access Training and help » microsoft+access+course - Attaching a msgbox/macro to a parameter

microsoft+access+course - Attaching a msgbox/macro to a parameter

resolvedResolved · 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

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

Edited on Wed 25 Apr 2007, 12:12

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


 

Access tip:

Combo box for finding records

You 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

View all Access hints and tips


Server loaded in 0.1 secs.