Solved

Access report behaves differently in preview vs. print

Posted on 2009-04-13
12
218 Views
Last Modified: 2013-11-28
I have a report that I make formatting changes when it opens based on the underlying table.  However when I preview it the formatting is OK, when I print the form directly the format is not correct.

Here is the code behind the report

Private Sub Report_Activate()
    '1 inch = 1440 twips
   
    If Me.LensMaterial = "Poly" Then Me.MHMaterial.Move Left:=7260, Top:=8520
   
    If Me.RxType = "Single Vision" Then
        Me.MHFT28.Visible = False
    Else
        Me.MHType.Move Left:=660, Top:=9180
        Me.MHFT28.Visible = True
    End If
   
End Sub

From another form here is the code that calls up the report:

DoCmd.OpenReport "rMassHealth", acViewPreview, , "(((tMain.TrayNo) Like [forms]![FMain]![TrayNo]))"


Any idea why this isn't working with printing directly?
0
Comment
Question by:thandel
  • 5
  • 4
  • 3
12 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 24135497
Printers and screens do not have the same resolution. There are always minor differences in output, but most of the time they are not noticeable because the human focus is on the data values not their position.
If you are doing very precise placement and/or sizing of controls for printing purposes, then you just have to test until the printing is correct and forget about what it looks like on the screen.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24137194
thandel,

Please define clearly what you mean when you say:
  "the format is not correct"
This can be interpreted as anything between "slightly off" to Completely Wrong"
Please clarify by providing a screen shot.
Thanks

As pete states, all printers distort.

What I always do is draw two lines that cross at the 1 inch mark and two lines that cross at the 2 inch mark.

Then set my code to toggle between these two points.
This way, as far as the "exact position" is concerned, it is correct.
(What it looks like on the screen or when printed is another story.)
Then I delete the lines as set my code to the actual positions

Also worth noting is that if you are using Access 2007 Print Preview and Report View are not exactly the same.

JeffCoachman

untitled.JPG
0
 

Author Comment

by:thandel
ID: 24143734
OK thanks I guess I should have been more clear.... This form is basically a form made op of a scanned form and then I have access fill ing the form using text boxes and to circle items on the forms I used squares.  The squares are what is giving me an issue.... depending on the data I will either more a square over to another selection or make it visible or not.  What is happening (or should I say not) is that the Private Sub Report_Activate is not executing when I open the report vs. previewing the report.  So all that code (see above) is not executing in print mode vs. preview mode and thus the boxes are either not moving as desired or the visible proprerty is not being set when trying to viewprint vs. viewpreview.

Is that clearer?
0
 
LVL 77

Expert Comment

by:peter57r
ID: 24143832
"Report_Activate is not executing when I open the report vs. previewing the report. "

That is correct. That is how Access works in reports. (This difference is used to detect whether a report is being previewed or being printed).
You will need to move your code to a different event; maybe a detail_format event or similar.
0
 

Author Comment

by:thandel
ID: 24143847
I'm not following, how can I get the code to execute prior to printing?
0
 

Author Comment

by:thandel
ID: 24143881
What about code to:

Preview the report
Then print automatically
Then close the report

What that work if there isn't any way to execute code prior to printing a form?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24144533
We really have no Visual "Context" for this issue.

Can you post a screenshot of what you have, and post a clear, graphical example of what you want it to look like.

Thanks

JeffCoachman
0
 

Author Comment

by:thandel
ID: 24144658
See attached printout.... the square boxes are what my code "moves" or make visible/not visible.  In print preview the above code is ecuted all is good.... in acviewnormal the code is not executed and the boxes are not moved/properities not set for visible.

Private Sub Report_Activate()
    '1 inch = 1440 twips
   
    If Me.LensMaterial = "Poly" Then Me.MHMaterial.Move Left:=7260, Top:=8520
   
    If Me.RxType = "Single Vision" Then
        Me.MHFT28.Visible = False
    Else
        Me.MHType.Move Left:=660, Top:=9180
        Me.MHFT28.Visible = True
    End If
   
End Sub
Report.jpg
0
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 24145175
"I'm not following, how can I get the code to execute prior to printing?"

The code you are using can be executed in the Format event procedure of the report section that contains the boxes.
(Right-click the section header bar and choose Build Event)
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24145185
Try putting the code on the Format Event of whatever section these boxes are in.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24145384
Sorry about that pete. (You know I'm a slow typist)

You can take over this Q.

;-)

Jeff
0
 

Author Closing Comment

by:thandel
ID: 31569783
Bingo thanks.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

758 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

19 Experts available now in Live!

Get 1:1 Help Now