Change print margins in queries - Access 2010

I've changed the margin settings in "Client Settings" to .25 for all 4 margins.  But every time I print query results, it defaults to 1" margins for all.

How do I change this?
Patty01AccessAsked:
Who is Participating?
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
I think the bottom line here is ... if ... you want to control the margins, you will need to use a Report.

mx
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
it works for me if I run the Print Preview the query, right click and select Page Setup and set to 0.25 ...

mx
Capture1.gif
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Patty01AccessAuthor Commented:
I want to set the .25" as the default.  I run a lot of queries that I need to print, and I want it to automatically default to .25" margins so I don't have to redo in page setup everytime.
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Well, in A2003 it was easy. That setting seems to have disappeared in A2010 ...


Capture1.gif
0
 
danishaniCommented:
You could create a User defined function for this, something like this:

Public Function OpenRptPreview(strReport As String)

Dim lngMargin As Long
' in twips 1440 = 1 inch
lngMargin = 320

DoCmd.OpenReport strReport, acViewPreview

With Reports!rptTest.Printer
.TopMargin = lngMargin
.BottomMargin = lngMargin
.LeftMargin = lngMargin
.RightMargin = lngMargin
End With

End Function

Open in new window


Save the Function in seperate Module, then in your database you can use the Function like:

OpenRptPreview("rptYourReportName")

Reports will open with margins set to 0.25 inch in Preview modus.

With this idea you can expand it to have the option with to Print etc.

Hope this helps,
Daniel
0
 
Patty01AccessAuthor Commented:
I'm sorry, but I don't know much about functions. I'm trying to do this for a query, not a report.

So I pasted the following into a new module:

Public Function OpenQry(strQuery As String)

Dim lngMargin As Long
' in twips 1440 = 1 inch
lngMargin = 320

DoCmd.OpenQuery strQuery, acViewPreview

With Query!qryMetroscanChk      (not sure what to put here, so I put the name of my query)
.TopMargin = lngMargin
.BottomMargin = lngMargin
.LeftMargin = lngMargin
.RightMargin = lngMargin
End With

End Function


But I get the error message "Object Required" and "With Query!qryMetroscanChk" is highlighted, so I know that's wrong.

Please help, and sorry for not knowing more about this!
0
 
danishaniCommented:
Sorry, my bad, thought you need this for your Report preview.

I am afraid the Query Object doesnt have this properties as far as I know of.

Another option is to use Application.SetOption to set Global variables. Only disadvantage is, it set's the default values for all Forms, Reports, Querys etc. objects to these margines as they are Global. But then you can overwrite them in Reports, using the above function for example.

For example:

Application.SetOption "Left Margin", 0.25
Application.SetOption "Right Margin", 0.25
Application.SetOption "Top Margin", 0.25
Application.SetOption "Bottom Margin", 0.25

Set all margin's to 0.25 inch.

Hope this helps,
Daniel

0
 
Jeffrey CoachmanMIS LiasonCommented:
Patty01Access,


...Then why not just create a simple Report (That will look just like the query) and print that...?
Then what you are requesting is ridiculously simple.

And you will also gain all the other advantages of using a report.
Headers, Footer, Code control, Page breaks, page numbering, more extensive formatting, Grouping, ...etc
0
 
Jeffrey CoachmanMIS LiasonCommented:
MX,

Yeah, I Think I remember a way to do what they are asking for, ...but I agree,
I see no reason why a simple report could not be created...

Enjoy the weekend buddy...

Jeff
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
see images ....
Capture1.gif
Capture2.gif
0
 
Patty01AccessAuthor Commented:
I prefer using the query because I change a lot of criteria and sorting.  And I use this query a lot.  So that's why I don't want to do it as a report.

So looks like the bottom line is you can't set the default margins for a query, which seems ridiculous.

Oh well, maybe in Access 2020.

0
 
Patty01AccessAuthor Commented:
Wish there was someone who knew how to do this, but seems like Access just won't let you do it in an easy enough way.  What a shame.
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.

All Courses

From novice to tech pro — start learning today.