?
Solved

Access report behaves differently in preview vs. print

Posted on 2009-04-13
12
Medium Priority
?
231 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
What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Suggested Courses

765 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