?
Solved

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

Posted on 2004-09-17
16
Medium Priority
?
442 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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
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 …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

800 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