Printing reports

G

Guest

I am attempting to printa current record on a report. This is the code I am
running
stDocName = "Flight#"
DoCmd.OpenReport "flight#", acNormal, , "[Flight_Number] =
forms![form1]![Flight_Number]"
It will only print a blank record this code works fine in other programs
the only difference between this file and other files is that (form1) in the
above code contains a subform . I have tried changing the form1 to the name
of the subform but I still get a blank record
Thanks for the help
T
 
D

Duane Hookom

First, I would highly recommend finding and using a naming convention that
doesn't include symbols in names of fields or objects.
Then consider changing the code to something like:
Dim strWhere as String
stDocName = "[Flight#]"
If IsNumeric(forms![form1]![Flight_Number]) Then
strWhere = "[Flight_Number] = " & forms![form1]![Flight_Number]
Else
strWhere = "[Flight_Number] = """ & forms![form1]![Flight_Number] &
""""
End If
MsgBox "Your strWhere: " & strWhere
DoCmd.OpenReport stDocName, acNormal, , strWhere
 

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