Print report from Form

K

Kelly

I have a form in which the user edits data. They want to
be able to print a report immediately after updating data
in the form. When the user clicks the print button on the
form, only the old data is printed, not the updates just
made. How do I write the changes to the db record before
the report is executed?

Thx,
Kelly
 
V

Van T. Dinh

What the user see on screen is the data in the Form's Current Record buffer
(which has not been updated into the Table) while the Report gets the data
from the Table.

You need to save / update the Record into the Table before running the
Report. You can use the statement:

DoCmd.RunCommand acCmdSaveRecord

in the existing CommandButton_Click Event to save the Record before opening
the Report.
 
F

fredg

I have a form in which the user edits data. They want to
be able to print a report immediately after updating data
in the form. When the user clicks the print button on the
form, only the old data is printed, not the updates just
made. How do I write the changes to the db record before
the report is executed?

Thx,
Kelly

You need to save the new data first.
Access doesn't save new data until you go to another (or new) record,
close the form, or explicitly tell it to.
Add one line of code the click event of the command button used to
print the report:

DoCmd.RunCommand acCmdSaveRecord

Then continue with whatever other code you have
 
J

Jim Allensworth

I have a form in which the user edits data. They want to
be able to print a report immediately after updating data
in the form. When the user clicks the print button on the
form, only the old data is printed, not the updates just
made. How do I write the changes to the db record before
the report is executed?

If Me.Dirty Then Me.Dirty = False

Put that at the top of the code to open/print the report.

- Jim
 
M

Marshall Barton

Kelly said:
I have a form in which the user edits data. They want to
be able to print a report immediately after updating data
in the form. When the user clicks the print button on the
form, only the old data is printed, not the updates just
made. How do I write the changes to the db record before
the report is executed?

You have to save the record before opening the report.
Here's a way to do it:

If Me.Dirty Then Me.Dirty = False
 
K

Kelly

Thanks! I knew there had to be a save record command, I
just couldn't find it! That works, too! I'm back in
business, for now.
 

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