Date range in header won't print correctly

M

Mary Beth

I have a report with the following text box in the header to print the report
date range:
="Follow Up Date Between: " & Forms.frmStEndDt.myStartDt & " and " &
Forms.frmStEndDt.myEndDt

The wording and dates are displayed correctly in the report prior to
printing it, however, when I print it, #Name? is in the header instead of the
label/dates. Can you help me fix this?
 
J

Jeff Boyce

Mary Beth

When Access says "#Name?", think "huh?!"

When Access can't find something named the way you named it, it displays
that "#Name?".

What happens if you use something like:

Forms!frmStEndDt!myStartDt

instead (using the "!" instead of the ".")?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
F

fredg

I have a report with the following text box in the header to print the report
date range:
="Follow Up Date Between: " & Forms.frmStEndDt.myStartDt & " and " &
Forms.frmStEndDt.myEndDt

The wording and dates are displayed correctly in the report prior to
printing it, however, when I print it, #Name? is in the header instead of the
label/dates. Can you help me fix this?

The correct syntax uses the bang (!):
Forms!frmStEndDt!myStartDt
Forms!frmStEndDt!myEndDt

If it previews properly but errors out when printing, that would
indicate that you have (either manually or by code) closed the form
after preview but before printing.

Check the report's code events for
DoCmd.Close acForm, "frmStEndDt"
 
M

Mary Beth

Thanks for the (!) correct syntax!! Actually, the problem may be the form
closing prior to printing. My code looks like this:
Case 2:
DoCmd.OpenReport "rptAvailableBalance", acViewPreview, , , ,
Me.myStartDt & "%" & Me.myEndDt
DoCmd.Close acForm, "frmStEndDt"

I've used this code before and don't have a problem, however, if it is
incorrect, what should I insert?
 
F

fredg

Thanks for the (!) correct syntax!! Actually, the problem may be the form
closing prior to printing. My code looks like this:
Case 2:
DoCmd.OpenReport "rptAvailableBalance", acViewPreview, , , ,
Me.myStartDt & "%" & Me.myEndDt
DoCmd.Close acForm, "frmStEndDt"

I've used this code before and don't have a problem, however, if it is
incorrect, what should I insert?

What is the purpose of sending the report the OpenArgs?
Me.myStartDt & "%" & Me.myEndDt <
Your code to display the date range is correctly pointing to the 2
controls on the form.
="Follow Up Date Between: " & Forms!frmStEndDt!myStartDt & " and " &
Forms!frmStEndDt!myEndDt

If the form STAYS OPEN, the unbound control in the report will read
those values.

Remove the
DoCmd.Close acForm, "frmStEndDt"
from the code that opens the report.

Case 2:
DoCmd.OpenReport "rptAvailableBalance", acViewPreview, , , ,
Me.myStartDt & "%" & Me.myEndDt


Then code the Report's Close event:
DoCmd.Close acForm, "frmStEndDt"
 
M

Mary Beth

The openArgs were from other code that I borrowed from something else and
thought that I needed it (I am a newer user to ACCESS). Thanks for all of
your help!!! This worked well and helped me understand the code/functions
much better!
 

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