I am having a small bug with some code I wrote and I did not notice at first. I am unsure how to describe it. The code is to open a cash register drawer using VBA. For some reason the code on click works excellent the first time used but it does not work great if I close the drawer and try again. If I wait a while and try again later or if I close access and reopen access it works again.
I even wrote a article to help others out and you can see it here: https://www.experts-exchange.com/articles/31507/MS-Access-How-To-Control-and-Open-a-POS-Cash-Register-Cash-Drawer-With-VBA.html
Anyway my code is:
Private Sub OpenCashDrawer()
On Error GoTo Errorhandler
Dim LocationPort As String
LocationPort = "Com4" 'Replace Com4 with the com port you are using. Example is Com3, Com2, etc.....
Open LocationPort & ":9600,n,8,1" For Output As #1
Print #1, "" 'This is just sending a signal like it is printing something but it is not.
MsgBox "Error " & Err.Number & ": " & Err.Description & " in " & _
VBE.ActiveCodePane.CodeModule, vbCritical, "Error in btnOpenCashDrawer_Click"
I believe it has something to do with the print call and it is (Not Really) printing something and I have to wait. Does anyone have any ideas.....
Thanks for the help.