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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

print preview is correct but actual print out is not

Status
Not open for further replies.

splats

Technical User
Jan 2, 2003
131
Hello

I have a report that works great with the exception that when it prints, it is missing the calculated fields for the date ranges. These are on the print preview but not on the print out. The criteria for the report are chosen from two text boxes for the date ranges on a form and then the report is executed from a command button.
Here are the two calculated fields on the report that do not end up printing.
=[Forms]![frmReports]![YearEnd].Value
=[Forms]![frmReports]![YearStart].Value

Any suggestions would be greatly appreciated.
 
tinat
Any chance that the form is being closed when the values are sent to the report? If the form is closed after preview, and prior to printing, then there is no way for the report to calculate the values.

Tom
 
Hello Tom

Thanks for your suggestion. The form does not close when the report is printed. Here is the code for the form command button to enable the Preview. I will try to Print it directly from this command button although I would prefer to preview it instead before printing. Of course I would prefer that it just print after I tell it to do so upon preview though. Any other ideas out there folks?

Private Sub cmdReport1_Click()
On Error GoTo Err_cmdReport1_Click

Dim stDocName As String

If BodyPart.Value = "" Then
MsgBox ("A Department must be selected to run this report")
GoTo Exit_cmdReport1_Click

Else
If YearStart.Value = "" Then
MsgBox ("A Start Year must be entered to run this report")
GoTo Exit_cmdReport1_Click

Else
If YearEnd.Value = "" Then
MsgBox ("An End Year must be entered to run this report")
GoTo Exit_cmdReport1_Click

Else

stDocName = "Incidents By Body Part"
DoCmd.OpenReport stDocName, acPreview
'DoCmd.OpenReport stDocName, acPrint

BodyPart.Value = ""
YearStart.Value = ""
YearEnd.Value = ""

End If
End If
End If

Exit_cmdReport1_Click:
Exit Sub

Err_cmdReport1_Click:
MsgBox Err.Description
Resume Exit_cmdReport1_Click

End Sub
 
tinat
I suspect that the following 3 lines are your problem.
Code:
BodyPart.Value = ""
 YearStart.Value = ""
 YearEnd.Value = ""

As soon as the report goes to Preview, the values are being reset to "" so when the report prints there is no value assigned to those fields.

Try commenting those lines out and see what happens.

Tom
 
tinat,
You probably have an issue with code like:
Code:
    If BodyPart.Value = "" Then
If there is no value in BodyPart, it will not equal a zero-length-string as you hope it would. You might need to change your code to something like:
Code:
   If Len(BodyPart.Value & "") = 0 Then
or
Code:
   If IsNull(Me.BodyPart) Then


Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top