Solved

Access report behaves differently in preview vs. print

Posted on 2009-04-13
12
230 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
[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
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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
 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

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.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
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…

691 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