Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 449
  • Last Modified:

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

How can I define the page margins dynamically (by code), in a Microsoft Access 2000 Report (.MDE File)?
0
EGITRON
Asked:
EGITRON
  • 5
  • 4
  • 3
  • +1
1 Solution
 
EGITRONAuthor Commented:
How to define the page margins dynamically, in a Microsoft Access 2000 Report (.MDE File)?
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
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
 
Rey Obrero (Capricorn1)Commented:
if it is an .MDE  you can't.
you can do it on  the .mdb version.
0
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

 
EGITRONAuthor Commented:
The big problem is that i'm trying to do this by code, in an .MDE...
0
 
stevbeCommented:
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
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
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
 
stevbeCommented:
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
 
Rey Obrero (Capricorn1)Commented:


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
 
stevbeCommented:
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
 
EGITRONAuthor Commented:
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
 
stevbeCommented:
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
 
EGITRONAuthor Commented:
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
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
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
 
EGITRONAuthor Commented:
I tried this code in a form, just before I open the report to print, and it's still not working. thanks anyway.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

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