Solved

Save and print VBA code

Posted on 2013-01-16
5
365 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

739 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