#name error when printing report

dkmoreland

Registered User.
Local time
Today, 13:54
Joined
Dec 6, 2017
Messages
129
I am using a form to pass a date range to a query and running a report based on that query.

On the report, I have a calculated field to display the date range. Here's the control source:

Code:
="Date Range: " & [Forms]![NCRs by Technology]![TxtStartDate] & " to " & [Forms]![NCRs by Technology]![TxtEndDate]

When I preview the report, the date range shows up correctly (see attached image). When I send the preview to the printer, I get a #name error.

Can anyone provide any insight? I figured that if the name reference was incorrect, it wouldn't even show up on the print preview. The #name error only shows up when I actually print it.

Thanks in advance.
 

Attachments

  • ncrs by tech screenshot.PNG
    ncrs by tech screenshot.PNG
    1.9 KB · Views: 133
Typing on a phone so can't alter code

Use Between..... And ....
Also use date delimiters #" & datefield & "#

Make sure your form is still open when the report opens as it needs the form references or save each of those values to variables and reference those instead
 
Last edited:
try adding 2 hidden textbox on the report.
on the report Load event:

private sub report_load()
me.unboundtxt1=[Forms]![NCRs by Technology]![TxtStartDate]
me.unboundtxt2=[Forms]![NCRs by Technology]![TxtEndDate]
end sub

now in the report header use the 2 txtbix:

" & [unboundtxt1] & " to " & [unboundtxt2]
 
Closing the form before printing the report was what was causing the problem - I didn't even think of that.

Thanks, everybody.
 
So - how can I hide the form, keep it open until the report is printed, then close the form?
 

Users who are viewing this thread

Back
Top Bottom