Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Page Margins of Access 2000 Report in VBA 2

Status
Not open for further replies.

gazza110

Technical User
Apr 14, 2004
42
0
0
GB
Hi,

Does anyone know a way of setting the page margins of a report when it loads in VBA?

Everytime the report opens on a different machine it resets the margins to the defaults. Is there a way to change these values using VBA ??

Thanks,
Gary.
 
Hi Gary,

I had a similar problem where I would work on the reports on my machine and they would change the margins. The reason for this was the other machine had a different printer connected ( a DVD printer in fact) So whatever I did to the report on my machine, it would reset the page settings so MY printer could print it. Try editing the page settings on the computer the database it is going to used on.


Ian Mayor (UK)
Program Error
There's ALWAYS more than one way to skin a cat!
But only one way to get it RIGHT!
 
Gary,

In the report's open event you can use the printer object to set the paper size, margins, etc so that it will be the same on each machine that is using the app. For example,

Private Sub Report_Open(Cancel As Integer)

Me.Printer.PaperSize = acPRPSLegal
Me.Printer.BottomMargin = 0.5 * 1440
Me.Printer.TopMargin = 0.5 * 1440
Me.Printer.LeftMargin = 0.5 * 1440
Me.Printer.RightMargin = 0.5 * 1440

End Sub

Keep in mind that one twip = 1/1440 of an inch so in the above example my margins have been set to half an inch. There are other settings you can change too such as the paper tray, portrait or landscape, manual feed, etc. Have a look at the "Printer" object.

Hope this helps.

Todd
 
Tman

Iz the Man!

I spent like 2 days trying to figure this one out, because I have some canned reports that users will have access to and because I opened up the printers to them it also gave them access to the page setup, your code should guarantee that whatever margins they set, will simply get reset upon opening.

By any chance do you know the code to keep the paper "portrait"?

Thanx!
 
For portrait try:

Me.Printer.Orientation = acPRORPortrait

Glad to be of help.

Todd
 
Thanx again, Tman!

The kind of stuff you'll never find in any of those 1500 page Access Bibles books
 
The title of this thread "Setting Page Margins of Access 2000 Report in VBA" relates to Access 2000. When I try to use the printer object methods stated by T Man, I get a "Method or Data member not found" error.

The link at MSDN


says that there is a printer object does not exist for Access 2000. Is that true?
 
I had no trouble using the settings mentioned by T Man. I am running Access 2002 but using Access 2000 format for the database.
 
Hi All- I am having the same trouble as IronBeaver. The Printer object does not exist for me. Is this a reference I need to turn on? I really need to get this to work. Anyone have any ideas? Thanks.
 
Hello all, I get the same error as IronBeaver "Method or Data member not found"

Has anybody found a fix for this yet?

Thanks,
 
If you are using Access2000, there is no printer object available, and as such, the solution posted by TMan will not work. You have 3 options:

1) Upgrade to a newer version of Access.
2) Programmatically set the report settings following the msdn link I provided above.
3) Update your office2000 with service pack 1a ( see )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top