Solved

Save and print VBA code

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
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…

820 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