Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Save and print VBA code

Posted on 2013-01-16
5
Medium Priority
?
370 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 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

715 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