Link to home
Start Free TrialLog in
Avatar of antmall
antmallFlag for United States of America

asked on

How can I prevent MS-Access VBA Code interruption during API Call when a user clicks the mouse.

I have a MS-Access Point-of-Sale application that makes an API call to process credit Cards.
My issue is that if the user clicks on the screen a few times the program responds with “Not Responding” in the Title of the current window and if they click enough times (it can vary), they can be greeted with this message:

User generated image

If the API transaction completes or if the user clicks “Wait for Application to complete”, everything will complete OK.

If the user clicks “close the program”, undesirable results are likely.
FYI: the API sends a message to their CC terminal, prompting the user to DIP (EMV)  or Tap (wireless, ApplePay) their credit card. Once the user Dips or Taps, it takes about 5-7 seconds to process and control sent back to the NS-Access application with a response Code. If the user does not Dip or Tap within 60 seconds, the transaction fails and send a response back to the MS-Access application.

I want to be able to lock up the screen so any mouse clicks and/or KB strokes are ignored until the API completes it’s mission.
The form VBA code calling the API is set as a Modal form. Even though Modal mode does not allow you click on another active form, the Access/VBA app appears to be processing the clicks in some way.

I have tried creating another Form just to process the API. This form is also set as Model and is hidden when opened. Results are the same.

Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

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


In my attempt to solve this problem, I Created a new Form to display a waiting message - don't touch the mouse ...
There are no other controls other than the text label. So on this form there is really nothing to click on .
The form is modal and the form that called this form is modal as well and all the controls on that form are disabled, but that should not matter - I think.
Displaying the message and disabling the control have to be done before call the API, as access has to wait for the API send back a response.

As for the API call, I am using MS XML 6.0 to make http POST

cBody = "code sent to API to process Credit Card such transaction Type, Transaction Amt, Terminal ID, etc)
xmlhttp.Open "POST", myurl, False
xmlhttp.setRequestHeader "Authorization", cAuthorizationID
xmlhttp.setRequestHeader "Content-type", "application/json"
xmlhttp.Send (cBody)
***  at this point Access is waiting for the API to return a response -This is the point where a user can click and cause problems
cResponseString = xmlhttp.responseText

I do not see how calling doevents would be helpful.


I have looked at the XML documentation, but so far I have not discovered a way call the XML as  a synchronous process.

I am hoping someone else might have some additional suggestions.

thanks to both of you for commenting.

Try to wait for the response
With objHTTP
    .Open "GET", sUrl2, True
    responseText = .responseText
  End With

Open in new window