Cmd button to print report.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have placed a command button on a Data Entry Form which runs a macro to
Print A Report of the newly entered data. The Report prints with blank fields
until the form is closed at least once. Ideas?
 
JJF,
Place a Refresh for the form, just before printing the report. The data
you entered had not yet been Updated and added to the table when you called
for the report.
 
I was referring to the VB code behind an Event Procedure. Sorry, but I
haven't ever used macros... they just too limited, and I perefer to have all
my code in the form module. Perhaps you could try a Requery in your print
report macro, since I don't see a Refresh available as a command.

How to code a form event...

If your button to print the report were named cmdPrintReport, in design
view, find the OnClick property for cmdPrintReport. Place your cursor in
the text box associated with OnClick, and select Event Procedure using the
arrow that appears on the right of the text box. Then, click the little box
on the right with the 3 dots.

You are now in the form module, and should see this...

Private Sub cmdPrintReport_Click()

End Sub

Add this code between the lines so it looks like...

Private Sub cmdPrintReport_Click()
Refresh
DoCmd.OpenReport "YourReportNameHere"
End Sub

Whenever the print button is Clicked, this code will update the newly
entered record values, and then print the report.
 
Back
Top