Link to home
Start Free TrialLog in
Avatar of Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.ScFlag for Zambia

asked on

Setting a POS printer in MS Access 2016

Hi

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
End If
DoCmd.Close acReport, rptName, acSaveYes

End Sub

Regards

Chris
ASKER CERTIFIED SOLUTION
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Chris,

 Just as an FYI, what the code is doing is what John suggested; opening the report in design view and adjusting the page settings.  

 This is the "old school" method however.  Access has the printer object and printers collection now which makes it simpler to deal with printing at run-time.   But again, just do what John suggested.

Jim.