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

Updating record for printing

Status
Not open for further replies.

Jarekb

Programmer
Mar 30, 2007
33
US
Private Sub Preview_Report_Click()

Dim stDocName As String
Dim strWhere As String

stDocName = "Replacement Debit Card Transmittal to Unit"
strWhere = "[New Card Number]='" & Me![New Card Number] & "'"

DoCmd.OpenReport stDocName, acPreview, , strWhere

I'm using the above code to print the current record displayed in the form, the only problem is after filling out the fields in the form I have to press the next record button for the table to update and for the print button to work properly.

What code can I add to the print button so that as it's clicked on it updates the table before trying to do the print preview part.
 
What you need is:

[tt]DoCmd.RunCommand accmdSaveRecord[/tt]
 
Where do I put that command. I added it before the DoCmd.OpenReport command and it didn't work.
 
What part of your record is not displaying properly? What updates when you move to the next record?
 
Clicking on the print preview button should send a numeric value to a report that needs to be printed out. When I fill out the form and click the button, the report pops up but all fields on it are blank. The only way to get it to work is to click next record, then go back to the original, and press the print preview button again. This time the report pops up with all fields populated.

The form contains a card number thats already filled in. The user types in an ID among other things. When the print button is clicked, the card number is sent to the report, the report has a query that looks at a table with card numbers and ID's, then it gets more info from other tables based on the ID. All this information should be displayed on the report, but if I don't click on the next record button then the table with card numbers and ID's doesn't update, so the report doesn't have an ID to use for the other tables.

 
And what about this ?
Private Sub Preview_Report_Click()
Dim stDocName As String
Dim strWhere As String
Me.Dirty = False
stDocName = "Replacement Debit Card Transmittal to Unit"
strWhere = "[New Card Number]='" & Me![New Card Number] & "'"
DoEvents
DoCmd.OpenReport stDocName, acViewPreview, , strWhere

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Just tried using Me.Dirty and no luck.
 
Amended my code to look like yours, with Me.Dirty = False and DoEvents, and still get same results as before.
 
Thanks Remou

Me.Refresh worked perfectly after I noticed that there were two sets of code for the same button. After deleting the second set and adding Mr.Refresh the report displays all information correctly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top