troubleshooting Question

How to use Loop in the serial port programming

Avatar of Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.ScFlag for Zambia asked on
ProgrammingMicrosoft AccessVBAJSON
5 Comments1 Solution46 ViewsLast Modified:
After working throughout last night on the serial USB Port to find out exactly what was causing Ms Access to hang/restart before finishing the second invoice,I discovered fortunately the main issue,Firstly, I had to use the note pad to divert the actual data that was coming out from the gadget to analysis it line by line including the commas & other characters and the results after comparing it with the gadget manual provided turned out as below:

(1) The QR code details were missing or not coming out of the gadget
(2) The CRC was also missing
(3) The closing Braces & Square brackets were also missing

Conclusion only 90% of the data were being extracted from the port leaving 10% inside, that is why Ms Access had a problem of hanging/restarting.

Help required

Extra VBA code to loop through the CommRead Function to force all the data to come out of the serial port before process any data and writing to the table. I'm trying the code below but it appears I'm missing it somewhere:

CommRead Function

' Read maximum of 2034 bytes from serial port.
    lngStatus = CommRead(intPortID, strData, 2036)
    'Do loop
    Do While lngStatus > 0
    If lngStatus < 0 Then
    Exit Do
    Set json = JsonConverter.ParseJson(Chr(91) & Mid(strData, 8) & Chr(34) & "}" & Chr(93))
    On Error Resume Next
    End If

Open in new window

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros