Print Button on Form

M

Marilee

I have a frustrating problem and need some advice. I have
a form that users complete and have a print button that
links to the appropriate report. The problem is that
sometimes when the user hits the print button, it doesn't
print the report properly (missing info). When I exit and
then go back in, it prints fine. What code do I use on
the print button so that the record updates before
printing?
 
A

Allen Browne

You need to save the record before you can print it.

Something like this:

Private Sub cmdPrintRecord_Click()
If Me.Dirty Then
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "Select a record to print."
Else
DoCmd.OpenReport "MyReport", acViewPreview, , "ID = " & Me.[ID]
End If
End Sub
 

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