Solved

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

Posted on 2004-09-17
16
435 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
Comment Utility
How to define the page margins dynamically, in a Microsoft Access 2000 Report (.MDE File)?
0
 
LVL 65

Expert Comment

by:Jim Horn
Comment Utility
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
Comment Utility
if it is an .MDE  you can't.
you can do it on  the .mdb version.
0
 

Author Comment

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

Expert Comment

by:stevbe
Comment Utility
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
Comment Utility
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
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility


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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…

771 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

11 Experts available now in Live!

Get 1:1 Help Now