Solved

Save and print VBA code

Posted on 2013-01-16
5
358 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 500 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now