Setting Query to open on Lanscape and Legal

  • Thread starter Thread starter Sok Hong
  • Start date Start date
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
 
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.
 
Back
Top