Start and End Dates not appearing in text box of report

C

ChuckW

Hi,

I created a form called SelectDates that has two text
boxes and a command button that runs a report. The two
text boxes are called txtStartDate and txtEndDate. I
created a query that has the following in the criteria of
the date restrictor:

Between [Forms]![SelectDates]![txtStartDate] And [Forms]!
[SelectDates]![txtEndDate]

The report correctly runs a sales report with this date
restrictor. One problem I am having is that I would like
for the start date and end date to appear in the header
of my report so that if it is printed out, the start
dates and end dates will appear. I created a text box at
the top of my report with the following values in the
first box = [Forms]![SelectDates]![txtStartDate].

I then created a second box with the following values
[Forms]![SelectDates]![txtEndDate]. I am expecting for
the start date and end dates to appear on the report but
I am getting the #Name? error instead. Any idea what I
am doing wrong.

Thanks,

Chuck
 
F

fredg

Hi,

I created a form called SelectDates that has two text
boxes and a command button that runs a report. The two
text boxes are called txtStartDate and txtEndDate. I
created a query that has the following in the criteria of
the date restrictor:

Between [Forms]![SelectDates]![txtStartDate] And [Forms]!
[SelectDates]![txtEndDate]

The report correctly runs a sales report with this date
restrictor. One problem I am having is that I would like
for the start date and end date to appear in the header
of my report so that if it is printed out, the start
dates and end dates will appear. I created a text box at
the top of my report with the following values in the
first box = [Forms]![SelectDates]![txtStartDate].

I then created a second box with the following values
[Forms]![SelectDates]![txtEndDate]. I am expecting for
the start date and end dates to appear on the report but
I am getting the #Name? error instead. Any idea what I
am doing wrong.

Thanks,

Chuck

Chuck,
Your method would work, BUT the form MUST still be open when the
report is run.
Here is an alternative, using just one unbound control in the report
header.
= "For sales between " & [Forms]![SelectDates]![txtStartDate] & " and
" [Forms]![SelectDates]![txtEndDate]

Code the Report's Open event to open the form "SelectDates".
DoCmd.OpenForm "SelectDates", , , , , acDialog

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

Code that command button on the Form:
Me.Visible = False

Now run the report.
When the report opens it will open the form.
Enter the start and end dates. Click the command button.
The Report will display/print. when the report closes, it will also
close the form.

The dates will show on the report header.
 

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