Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Save and print VBA code

Posted on 2013-01-16
5
Medium Priority
?
372 Views
Last Modified: 2013-01-17
Hi guys,

I have a command button and behind it the following code:
"Private Sub TRS_PRINT_APP_Click()
Transpose1 Me.APPLICATIO
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "File_Report", WhereCondition:="APP = '" & Me.APPLICATIO & "'"
End Sub"
When I click the button the first time an empty report corresponding to the current form record is printed.
When I click the button the second time the report corresponding to the current form record is printed properly.
("Transpose1" is the code to transpose the form records and the table resulted from transposition is used in a query representing the record source for report)
Thank you
0
Comment
Question by:marian68
  • 3
5 Comments
 
LVL 7

Expert Comment

by:karunamoorthy
ID: 38783130
use display statements to inspect the intermediate results for debugging
0
 

Author Comment

by:marian68
ID: 38783176
Give me please more details.
0
 

Author Comment

by:marian68
ID: 38783786
Any other ideas please?
0
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 38787500
Try flipping the first two statements around.  You want to save your data before running your transpose function:

Private Sub TRS_PRINT_APP_Click()

DoCmd.RunCommand acCmdSaveRecord
Transpose1 Me.APPLICATIO

DoCmd.OpenReport "File_Report", WhereCondition:="APP = '" & Me.APPLICATIO & "'"
End Sub

Open in new window

0
 

Author Closing Comment

by:marian68
ID: 38787518
Thanks a lot
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question