Solved

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

Posted on 2004-09-17
16
436 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
  • 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 65

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 119

Expert Comment

by:Rey Obrero
ID: 12086394
if it is an .MDE  you can't.
you can do it on  the .mdb version.
0
 

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 65

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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 119

Accepted Solution

by:
Rey Obrero 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 65

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Access 2016 Debugging 7 42
Create Form using Wizard 14 31
Getting Run-Time Error 13 - Type Mismatch 3 25
Search Form not Querying 2 10
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

914 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now