Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

STL - Formerly Best Training Solutions Through Learning
TrustPilot
Excellent
Request Callback We will call you back
0207 987 3777 Call for assistance
Your Basket Basket is empty
microsoft+access+course - attaching msgboxmacro parameter

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

ResolvedVersion 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:

How To Find All Overdue Accounts?

To find overdue accounts create a filter that compares today's date with the Invoice Date in the table. To do this:

1. Open the Query in Design View
2. Select the field for the filter and in the criteria row enter:

<Date()

This filter returns records where the Invoice Date is before today's date.

This filter can be manipulated if, for instance, Invoices are due 15 days after the Invoice Date. For this the filter would be:

<Date()-15

This filter returns records where the Invoice Date is 15 days before today's date.

View all Access hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.