Solved

How to define the page margins dynamically, in a Microsoft Access 2000 Report (.MDE File)?

Posted on 2004-09-17
16
441 Views
Last Modified: 2013-12-05
How can I define the page margins dynamically (by code), in a Microsoft Access 2000 Report (.MDE File)?
0
Comment
Question by:EGITRON
[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
  • +1
16 Comments
 

Author Comment

by:EGITRON
ID: 12086229
How to define the page margins dynamically, in a Microsoft Access 2000 Report (.MDE File)?
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 12086336
Use the Printer object in code...
__________________

Dim oPrinter as Access.Printer
Set oPrinter = Application.Printers(0)  '0=Default

With oPrinter
   .TopMargin =  {inches}
   .BottomMargin =  {inches}
    .LeftMargin = {inches}
    .RightMargin =  {inches}
    .Orientation ={1=lanscape|0=portrait}
    .PaperSize = {?}
    .PrintQuality = {?}
end with

___________
If you really want to go all out, you can create a table of report information and table-drive this.

Hope this helps.
-Jim

0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 12086394
if it is an .MDE  you can't.
you can do it on  the .mdb version.
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

 

Author Comment

by:EGITRON
ID: 12086443
The big problem is that i'm trying to do this by code, in an .MDE...
0
 
LVL 39

Expert Comment

by:stevbe
ID: 12086493
To expand on what capricorn said ... to change the report you would need to open the report in design mode and you cannot do that with an mde.

Why do you need to change the margins? Perhaps we can suggest an alternative like changing the .Left and .Width properties of the controls on the report itself which you can do with runtime.

Steve
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 12086494
cap:  Have you tested this before?  I know reports aren't editable, but I always through Printer properties were.  The only project I pulled this off on was an .mdb, so I don't know myself.  -Jim
0
 
LVL 39

Expert Comment

by:stevbe
ID: 12086513
You can change the printer settings but I think that is not going to work for this problem because if you size the report to the smallest needed and then change the printer margins to be larger it will not affect the report contrrol placement at all and if you did it the other way around, with the report being largest necessary and you made the printer margins smaller you would get page over runs.

Steve
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 12086537


about .mde

Saving your Access database as an MDE file prevents the following actions:

Viewing, modifying, or creating forms, reports, or modules in Design view.
Adding, deleting, or changing references to object libraries or databases.
Changing code — an MDE file contains no source code.
Importing or exporting forms, reports, or modules. However, tables, queries, data access pages, and macros can be imported from or exported to non-MDE databases.

*************
Considerations if you need to modify the design of forms, reports, or modules
*************
Be sure to keep a copy of your original Access database. If you need to modify the design of forms, reports, or modules in an MDE file, you must modify the original Access database, and then resave it as an MDE file. Saving an Access database containing tables as an MDE file creates complications reconciling different versions of the data if you need to modify the design of the forms, reports, or modules later. For this reason, saving an Access database as an MDE file is most appropriate for the front-end database of a front-end/back-end application.

0
 
LVL 39

Expert Comment

by:stevbe
ID: 12086574
another note about mde ... an mde can only run on a machine that has the same version as the machine that compiles the mde. So although you can use an mdb made in 2000 if you have 2002 on your machine the same is not true for mde.

Steve
0
 

Author Comment

by:EGITRON
ID: 12100644
jimhorn: I’m trying to use the code you provide me, but I can't compile the first line:
     Dim oPrinter as Access.Printer
Is "Access.Printer" a datatype?
Can you please give me a complete example, of how to put this to work? Thanks
0
 
LVL 39

Expert Comment

by:stevbe
ID: 12100938
The Printers collection and Printer object were not available until 2002. There is code wrapped in classes to to work with printers in Access 2000 Desktop Developers Handbook but it requires that you are able to open the report in design mode which you cannot do in an mde.

Steve
0
 

Author Comment

by:EGITRON
ID: 12101918
jimhorn: I have just converted the application to Access XP, but I can't still put that code to work. I can now compile, and I define a value for the .TopMargin, but nothing happens. where exactly whould I put that code?
By the way, thanks for the tip, stevbe.
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 12102532
Access.Printer is the Access VBA code's Printer object, which inherits properties from all the printers you have access to.  Many of these are read-write.   The above example is complete enough, if it's not then perhaps you should post this as a separate EE question.

On the project I used this code on, I executed it in a separate code module before calling the report.  I don't believe you can put this code in the report, such as Report.Open, and have it execute correctly.

Hope this helps.
-Jim
0
 

Author Comment

by:EGITRON
ID: 12103722
I tried this code in a form, just before I open the report to print, and it's still not working. thanks anyway.
0

Featured Post

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

Question has a verified solution.

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

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…
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

726 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