• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 239
  • Last Modified:

Access report behaves differently in preview vs. print

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
thandel
Asked:
thandel
  • 5
  • 4
  • 3
1 Solution
 
peter57rCommented:
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
 
Jeffrey CoachmanMIS LiasonCommented:
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
 
thandelAuthor Commented:
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
peter57rCommented:
"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
 
thandelAuthor Commented:
I'm not following, how can I get the code to execute prior to printing?
0
 
thandelAuthor Commented:
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
 
Jeffrey CoachmanMIS LiasonCommented:
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
 
thandelAuthor Commented:
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
 
peter57rCommented:
"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
 
Jeffrey CoachmanMIS LiasonCommented:
Try putting the code on the Format Event of whatever section these boxes are in.
0
 
Jeffrey CoachmanMIS LiasonCommented:
Sorry about that pete. (You know I'm a slow typist)

You can take over this Q.

;-)

Jeff
0
 
thandelAuthor Commented:
Bingo thanks.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 5
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now