Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

#Name? appears when printing the report 2

Status
Not open for further replies.

qwerty70

Technical User
Dec 13, 2005
73
GB
I have a form that has a date parameter prior to printing a report. Whenever I preview the report, the date range that I supplied appears in my report without any problem, i.e. "Data entry from 9/1/07 to 12/1/07", but when I print the report an error "#Name?" appears in the print-out.

Here's the code which I used in my report's textbox control source:

Code:
="Data entry from " & ([forms]![frmVenDocEntry]![txtDateFrom]) & " to " & ([forms]![frmVenDocEntry]![txtDateTo])

Please help the novice.

Thanks,

qwerty70
 
Is frmVenDocEntry still open when you print the report ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV,

frmVenDocEntry is closed when I print the report.

Here's the code behind the cmdReport button on my frmVenDocEntry form:

Code:
Private Sub cmdReport_Click()
    On Error GoTo Err_cmdReport_Click

    Dim stDocName As String

    stDocName = "rptVenDoc"
    
'Check values are entered into Date From and Date To text boxes
'if so run report or cancel request

    If Len(Me.txtdatefrom & vbNullString) = 0 Or Len(Me.txtDateTo & vbNullString) = 0 Then
        MsgBox "Please ensure that a report date range is entered into the form", _
               vbInformation, "Required Data..."
        Exit Sub
    Else
        DoCmd.OpenReport stDocName, acPreview
        DoCmd.Close acForm, Me.Name
    End If
Exit_cmdReport_Click:
    Exit Sub

Err_cmdReport_Click:
    MsgBox Err.Description
    Resume Exit_cmdReport_Click

End Sub

Thanks,

qwerty70
 
Replace this:
DoCmd.OpenReport stDocName, acPreview
with this:
DoCmd.OpenReport stDocName, acViewPreview, , , acDialog

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How are ya qwerty70 . . .

The form has to be open for access by the report! Try the following:
[ol][li]In the reports [blue]On Open[/blue] event, hide the form:
Code:
[blue]   Forms![purple][b]FormName[/b][/purple].Visible = False[/blue]
[/li]
[li]In the reports [blue]On Close[/blue] event, close the form:
Code:
[blue]   DoCmd.Close acForm, "[purple][b]FormName[/b][/purple]"[/blue]
[/li][/ol]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
PHV & TheAceman1, thank you. Both solutions solved my problem.

Appreciate your help.

Regards,

qwerty70
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top