Avatar of antmall
antmall
Flag 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:

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.
 
 
 

VBAMicrosoft Access

Avatar of undefined
Last Comment
John Tsioumpris

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Ryan Chong

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Jim Dettman (EE MVE)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
antmall

ASKER
Ryan
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.

Jim

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.

Bruce
John Tsioumpris

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

Open in new window

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy