Solved

printing a report based on information in a form that is on screen

Posted on 2012-04-03
2
304 Views
Last Modified: 2012-08-14
I have a form that i have created and at the top of the form i created a command button the user can press to print a report based on the information they have put in the form.  The field that I use as the control field is called Bill.  Once the form is filled out they press a button at the top labeled Print and they are supposed to see a print preview of a report that has the information they just typed into the form.  The form accepts all the information and the table retains all of the data but the report is blank.  Below is the code i am using for on click of the command button i created.

Private Sub Command156_Click()
On Error GoTo Err_Command156_Click
DoCmd.OpenReport "P1BOL", acViewPreview, , "[Bill]=" & Me.Bill
        Dim stDocName As String
        stDocName = "P1BOL"
        DoCmd.OpenReport stDocName, acPreview
       
Exit_Command156_Click:
Exit Sub

Err_Command156_Click:
 MsgBox Err.Description
 Resume Exit_Command156_Click

       
End Sub
0
Comment
Question by:AisinAuto
2 Comments
 
LVL 47

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 250 total points
ID: 37801190
You need to make sure that the current record is saved first.  Try:

Private Sub Command156_Click()

    On Error GoTo Err_Command156_Click

    me.Dirty = false
    DoCmd.OpenReport "P1BOL", acViewPreview, , "[Bill]=" & Me.Bill

Exit_Command156_Click:
    Exit Sub
Err_Command156_Click:
 MsgBox Err.Description
 
End Sub
0
 
LVL 77

Accepted Solution

by:
peter57r earned 250 total points
ID: 37801194
You need to be sure you have saved the current record before opening your report.

Add
Me.Dirty = False
at the start of your code.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
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…

803 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