#Name? on report instead of field

connie

Registered User.
Local time
Today, 15:15
Joined
Aug 6, 2009
Messages
92
Hi,

I have a form with combo boxes, and when the user makes their selections and clicks the command button, it feeds into a query and opens a report based on that query.

The report all works fine, except this. In the header of the report I put fields that are supposed to show what the user selected in the combo boxes, and if nothing was specified, than I want those fields to read "All." I used:

=IIf([Forms]![frmBuildCustomReport]![cboContractor] Is Null,"All",[Forms]![frmBuildCustomReport]![cboContractor])

For some reason, when the report opens up it looks exactly how I want it on the screen, but when I print it, it prints these fields as "#Name?"

Can anyone assist?
 
Try this.

Code:
=IIf(IsNull([Forms]![frmBuildCustomReport]![cboContractor]),"All",[Forms]![frmBuildCustomReport]![cboContractor])
 
Try this.

Code:
=IIf(IsNull([Forms]![frmBuildCustomReport]![cboContractor]),"All",[Forms]![frmBuildCustomReport]![cboContractor])

Thank you...no, it still does the same thing. Looks perfect on screen but prints with "#Name?" However the detail of the report prints fine.

The code is written to close the form & query and bring up the report, and I'm wondering if this has something to do with it...because if you tried to open the report by itself without going through the form that feeds the query, those IIf fields I put in the header will say #Name?

Ok, I've removed the line of VBA DoCmd.Close acForm, "frmBuildCustomReport" so that the form where user made combo box selections doesn't automatically close when the report comes up. This has fixed the error that prints, and all works fine. But I would prefer to have it the original way where the form can automatically close without erroring out these fields in the header. Any ideas?

Thanks!!
 
But I would prefer to have it the original way where the form can automatically close without erroring out these fields in the header.

You also wrote: "it feeds into a query and opens a report". You may want to close your form with the one of the report's events, such as open/load/current. However, a word of caution; the code your presented gets its values from the form. So you will need to verify that the report has "access" to the data you want at the time it prints. You may be closing your form to early.
 
You could try to 'hide' the form when the report opens and use the onopen in the report to then close the form.

Code:
cdocmd.RunCommand acCmdWindowHide

You can then use the report's OnOpen event to close form using

Code:
docmd.close "FormName",acsave-Yes/No/Prompt-choose 1
 

Users who are viewing this thread

Back
Top Bottom