Dialog Box Input Mask

T

Tom G

I have a simple parameter dialog box for the user to enter a date to search.
The problem is this field is a date/time field and returns NOTHING if they
don't enter in the correct date format --/--/----. I want a sample data or
input mask in the dialog box text field. Possible?


Like [Enter Date: ] & "*"
 
F

fredg

I have a simple parameter dialog box for the user to enter a date to search.
The problem is this field is a date/time field and returns NOTHING if they
don't enter in the correct date format --/--/----. I want a sample data or
input mask in the dialog box text field. Possible?

Like [Enter Date: ] & "*"


No it's not possible.

If you are actually opening the query (not using the query as record
source for a report), then ....
Create a form for the entry of the parameter.
Add an unbound text control.
Set the control's Format to Short Date.
Name this control 'FromDate'.

The above control format will force a valid date entry, however we'll
add some code to the form to verify that it is a date.

Add a command button to the form

Code the button's Click event:
If IsDate(Me![FromDate]) Then
DoCmd.OpenQuery "QueryName"
DoCmd.Close acForm, Me.Name
Else
MsgBox "Enter a valid date."
End If

Name this form 'ParamForm'

Change your query parameter from:
Like [Enter Date: ] & "*"
To..
=forms!ParamForm!FromDate

When you wish to run the query open the form. Enter the date and click
the command button. The query will display and the form will close.
 
T

Tom G

Thanks, Fredg. I forgot to mention that I am using the query results as a
data source for a report that will utimately be emailed. Thats good info to
know though, I think I can use it some place else.

Thanks Again



fredg said:
I have a simple parameter dialog box for the user to enter a date to search.
The problem is this field is a date/time field and returns NOTHING if they
don't enter in the correct date format --/--/----. I want a sample data or
input mask in the dialog box text field. Possible?

Like [Enter Date: ] & "*"


No it's not possible.

If you are actually opening the query (not using the query as record
source for a report), then ....
Create a form for the entry of the parameter.
Add an unbound text control.
Set the control's Format to Short Date.
Name this control 'FromDate'.

The above control format will force a valid date entry, however we'll
add some code to the form to verify that it is a date.

Add a command button to the form

Code the button's Click event:
If IsDate(Me![FromDate]) Then
DoCmd.OpenQuery "QueryName"
DoCmd.Close acForm, Me.Name
Else
MsgBox "Enter a valid date."
End If

Name this form 'ParamForm'

Change your query parameter from:
Like [Enter Date: ] & "*"
To..
=forms!ParamForm!FromDate

When you wish to run the query open the form. Enter the date and click
the command button. The query will display and the form will close.
 
F

fredg

Thanks, Fredg. I forgot to mention that I am using the query results as a
data source for a report that will utimately be emailed. Thats good info to
know though, I think I can use it some place else.

Thanks Again

fredg said:
I have a simple parameter dialog box for the user to enter a date to search.
The problem is this field is a date/time field and returns NOTHING if they
don't enter in the correct date format --/--/----. I want a sample data or
input mask in the dialog box text field. Possible?

Like [Enter Date: ] & "*"

No it's not possible.

If you are actually opening the query (not using the query as record
source for a report), then ....
Create a form for the entry of the parameter.
Add an unbound text control.
Set the control's Format to Short Date.
Name this control 'FromDate'.

The above control format will force a valid date entry, however we'll
add some code to the form to verify that it is a date.

Add a command button to the form

Code the button's Click event:
If IsDate(Me![FromDate]) Then
DoCmd.OpenQuery "QueryName"
DoCmd.Close acForm, Me.Name
Else
MsgBox "Enter a valid date."
End If

Name this form 'ParamForm'

Change your query parameter from:
Like [Enter Date: ] & "*"
To..
=forms!ParamForm!FromDate

When you wish to run the query open the form. Enter the date and click
the command button. The query will display and the form will close.

Use the same form information AND the same query information,
EXCEPT ......

Change the code of the form's Command Button to:

If IsDate(Me![FromDate]) Then
Me.Visible = False
Else
MsgBox "Enter a valid date."
End If


Code the Report's Open Event:
DoCmd.OpenForm "ParamForm", , , , , acDialog

Code the Report's Close event:
DoCmd.Close acForm, "ParamForm"

In this case, open the report. The report will open the form. enter
the date and click the command button. The report will display. When
the report closes, it will close the form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top