Date Range Dialog Box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a dialog box that requests the date range for a report and it works
fine for that report. I'm simply using a macro to open that particular
report when the OK command button is clicked. Is there a way--using macros
or VBA--to make this one dialog box work for multiple reports? Thanks in
advance!
 
Through macros? Probably.

Lets say your form is named frmDateRange.
You have a control txtDateStart and txtDateEnd.

You also have a close button. But, instead of closing it, you actually
just hide the form. On the OnClick event of the close button, use:

Me.Visible = True

Your macro should open this form modally, then open any report. The
report's query source should have:

[DateFieldName]
Condition:
Between Forms!frmDateRange!txtDateStart and
Forms!frmDateRange!txtDateEnd


Let me know if that doesn't make sense.


Chris Nebinger
 
Thank you. I will give this a try.

Through macros? Probably.

Lets say your form is named frmDateRange.
You have a control txtDateStart and txtDateEnd.

You also have a close button. But, instead of closing it, you actually
just hide the form. On the OnClick event of the close button, use:

Me.Visible = True

Your macro should open this form modally, then open any report. The
report's query source should have:

[DateFieldName]
Condition:
Between Forms!frmDateRange!txtDateStart and
Forms!frmDateRange!txtDateEnd


Let me know if that doesn't make sense.


Chris Nebinger

I have a dialog box that requests the date range for a report and it works
fine for that report. I'm simply using a macro to open that particular
report when the OK command button is clicked. Is there a way--using macros
or VBA--to make this one dialog box work for multiple reports? Thanks in
advance!
 
Yes, I am confused. I have a macro attached to the OK command button on my
form which opens a specific report with the specified date range. If I use a
macro to open the form, how do I open a report? In other words, how do I
program the OK button to work with any report since I have to specify a
report name using the OpenReport action?

If macros are too simplistic for this, how can I code this using VBA?

Through macros? Probably.

Lets say your form is named frmDateRange.
You have a control txtDateStart and txtDateEnd.

You also have a close button. But, instead of closing it, you actually
just hide the form. On the OnClick event of the close button, use:

Me.Visible = True

Your macro should open this form modally, then open any report. The
report's query source should have:

[DateFieldName]
Condition:
Between Forms!frmDateRange!txtDateStart and
Forms!frmDateRange!txtDateEnd


Let me know if that doesn't make sense.


Chris Nebinger

I have a dialog box that requests the date range for a report and it works
fine for that report. I'm simply using a macro to open that particular
report when the OK command button is clicked. Is there a way--using macros
or VBA--to make this one dialog box work for multiple reports? Thanks in
advance!
 
On the line right above your OpenReport action, use a OpenForm action.
Set the Window Mode to Dialog. This will cause the macro to pause
while the form is open.

On the OnClose event, use VBA code, and set the visibile property of
the form to false. This hides the form, but leaves it open for your
query to access the values. Once the form is hidden, the macro runs
the next line, which opens the report. The recordsource of the report
is the query with the conditions set, which evaluate to find the form
you have hidden, and enters those values.

After the report open action, you should close the form that has the
date ranges with a standard Close action.

Does that help?


Chris



Yes, I am confused. I have a macro attached to the OK command button on my
form which opens a specific report with the specified date range. If I use a
macro to open the form, how do I open a report? In other words, how do I
program the OK button to work with any report since I have to specify a
report name using the OpenReport action?

If macros are too simplistic for this, how can I code this using VBA?



Through macros? Probably.
Lets say your form is named frmDateRange.
You have a control txtDateStart and txtDateEnd.
You also have a close button. But, instead of closing it, you actually
just hide the form. On the OnClick event of the close button, use:
Me.Visible = True
Your macro should open this form modally, then open any report. The
report's query source should have:
[DateFieldName]
Condition:
Between Forms!frmDateRange!txtDateStart and
Forms!frmDateRange!txtDateEnd
Let me know if that doesn't make sense.
Chris Nebinger
 
Yes it does; thank you!

On the line right above your OpenReport action, use a OpenForm action.
Set the Window Mode to Dialog. This will cause the macro to pause
while the form is open.

On the OnClose event, use VBA code, and set the visibile property of
the form to false. This hides the form, but leaves it open for your
query to access the values. Once the form is hidden, the macro runs
the next line, which opens the report. The recordsource of the report
is the query with the conditions set, which evaluate to find the form
you have hidden, and enters those values.

After the report open action, you should close the form that has the
date ranges with a standard Close action.

Does that help?


Chris



Yes, I am confused. I have a macro attached to the OK command button on my
form which opens a specific report with the specified date range. If I use a
macro to open the form, how do I open a report? In other words, how do I
program the OK button to work with any report since I have to specify a
report name using the OpenReport action?

If macros are too simplistic for this, how can I code this using VBA?



Through macros? Probably.
Lets say your form is named frmDateRange.
You have a control txtDateStart and txtDateEnd.
You also have a close button. But, instead of closing it, you actually
just hide the form. On the OnClick event of the close button, use:
Me.Visible = True
Your macro should open this form modally, then open any report. The
report's query source should have:
[DateFieldName]
Condition:
Between Forms!frmDateRange!txtDateStart and
Forms!frmDateRange!txtDateEnd
Let me know if that doesn't make sense.
Chris Nebinger
msgulf wrote:
I have a dialog box that requests the date range for a report and it works
fine for that report. I'm simply using a macro to open that particular
report when the OK command button is clicked. Is there a way--using macros
or VBA--to make this one dialog box work for multiple reports? Thanks in
advance!- Hide quoted text -- Show quoted text -
 

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

Back
Top