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
LVL 3
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.ScDirectorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John TsioumprisSoftware & Systems EngineerCommented:
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 code...it seems that there are       " dark areas " in the report "ecosystem"...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mark EdwardsChief Technology OfficerCommented:
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 (Microsoft MVP/ EE MVE)President / OwnerCommented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Accounting

From novice to tech pro — start learning today.