Printing reports

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
Back
Top