Setting a POS printer in MS Access 2016

Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc used Ask the Experts™

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


Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software & Systems Engineer
The simplest way to resolve is to open the report in Design and go to the Page Setup-->Page Setup --> Page-->Size ...just remember to select the thermal printer as default in order to pick the paper size...(tip : if the paper size is not listed you have to manually create it  Devices-->Printers -->Printer Server Properties---> Here you maunally add a paper with the acceptable paper size of the POS)
In my personal experience..paper sizes that are not in the default list by Microsoft are not handled very well in seems that there are       " dark areas " in the report "ecosystem"...
Mark EdwardsChief Technology Officer
Just be aware that "design view" is NOT available in an Access .mde, .accde, or .ade.  Not even by VBA code.  I tried - it doesn't work.
Jim Dettman (EE MVE)President / Owner
Most Valuable Expert 2017
Most Valuable Expert 2012


 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.


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial