Setting Query to open on Lanscape and Legal

S

Sok Hong

Hello, I've copied this code from a microsoft website.
It's suppposed to set reports on a Legalsize, landscape
view. However, I've tried changing this code to work for
a query instead but doesn't seem to be working. Any
thoughts? "Dim qry As Query" seems to give the problem.

Public Function SetLegalSize(strName As String)
Dim qry As Query
Dim strDevModeExtra As String
Dim DevString As str_DEVMODE
Dim DM As type_DEVMODE

DoCmd.OpenQuery strName, acDesign 'Opens Query in Design
view.

Set qry = Query(strName)

If Not IsNull(qry.PrtDevMode) Then
strDevModeExtra = qry.PrtDevMode
DevString.RGB = strDevModeExtra
LSet DM = DevString
DM.lngFields = DM.lngFields Or
DM.intOrientation 'Initialize fields.
DM.intPaperSize = 5 'Legal size
DM.intOrientation = 2 'Landscape
LSet DevString = DM 'Update property.
Mid(strDevModeExtra, 1, 94) = DevString.RGB
qry.PrtDevMode = strDevModeExtra
DoCmd.Save acQuery, strName
DoCmd.Close acQuery, strName
End If

End Function
 
J

John Vinson

However, I've tried changing this code to work for
a query instead but doesn't seem to be working. Any
thoughts?

Reports are designed for printing, and know about things like
landscape and margin. Queries are not designed for printing, and
don't; query datasheets should be used only for design and debugging,
not for reporting. Just use a Report based on your query.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Save action cancelled 3
Interfacing to Adobe 3

Top