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