I have a point of sales module within the main accounting application , now when printing it is accepting only to print on A4 Paper which is a waste of paper, I have no problem when printing ledgers but a pos receipt must come on a thermal receipt printer and paper size is about 80mm. While discusing about this yesterday someone passed the below code to me to study it and see may be it can sort out the problem. To be honest I did not understand it how it works and where to put either in the report module or a function,kindly can someone help me on this, some may have come up with this before.
(1) It appears like it first opens the report in design mode and that is where I do not understand it!
Sub sSwitchPaperSizeToLegal(rptName As String)
'The purpose of this sub is to set the page size
'for a report to legal
Const SUB_NAME$ = "sSwitchPaperSizeToLegal"
Dim DevString As str_DEVMODE
Dim DM As type_DEVMODE
Dim strDevModeExtra As String
Dim rpt As Report
'Open report in design view.
DoCmd.OpenReport rptName, acDesign 'Open report in Design view.
Set rpt = Reports(rptName)
If Not IsNull(rpt.PrtDevMode) Then
strDevModeExtra = rpt.PrtDevMode ' Get current DEVMODE structure.
DevString.RGB = strDevModeExtra
LSet DM = DevString
DM.lngFields = DM.lngFields Or DM.intPaperSize Or DM.intPaperLength Or DM.intPaperWidth
'DM.intPaperSize = 5 'legal
DM.intPaperWidth = 800 '80mm
DM.intPaperLength = 32760 '3276mm
LSet DevString = DM 'Update property.
Mid(strDevModeExtra, 1, 94) = DevString.RGB
rpt.PrtDevMode = strDevModeExtra
DoCmd.Close acReport, rptName, acSaveYes