Using hotkeys to call a macro - but how to exit gracefully (1 Viewer)

peskywinnets

Registered User.
Local time
Today, 10:37
Joined
Feb 4, 2014
Messages
576
So I'm using hotkeys to call macros - it all works well, but occasionally, I want to exit from a specific macro (scanning barcodes), so I've put a simple if statement, along the lines of....

Code:
UserScannedBarcode = InputBox("Now Scan the PRODUCT Barcode(s)")
If UserScannedBarcode = "e" Or UserScannedBarcode = "E" Then
DoCmd.Close acQuery, "ScanBarcodes"
[B]End[/B]
End If

...the problem (I think!) is that the 'End' only exits the VBA, which still takes me back to the original macro ...which then barfs....so my question is how can I exit VBA code & the parent macros instantly (without having to click on further onscreen messages)

thanks in anticipation.
 

Minty

AWF VIP
Local time
Today, 10:37
Joined
Jul 26, 2013
Messages
10,353
Why use a macro at all? Just do it all in VBA, macro's are not as flexible.
 

peskywinnets

Registered User.
Local time
Today, 10:37
Joined
Feb 4, 2014
Messages
576
Why use a macro at all? Just do it all in VBA, macro's are not as flexible.

Because (to my knowledge), the only way of being able to use hotkeys, is to trigger a macro ...& I really need to use hotkeys.
 

Minty

AWF VIP
Local time
Today, 10:37
Joined
Jul 26, 2013
Messages
10,353
You can use KeyDown events to check for keys being pressed, or simply call a VBA function with the hotkey macro, then you are beck in control within the code.
 

peskywinnets

Registered User.
Local time
Today, 10:37
Joined
Feb 4, 2014
Messages
576
You can use KeyDown events to check for keys being pressed, or simply call a VBA function with the hotkey macro, then you are beck in control within the code.

Re the bolded bit, that's what I'm doing ...calling some VBA code with a hotkey macro....but it doesn't allow me to exit the VBA cleanly (I get a further message onscreen, when the VBA returns back to the originating macro)

You can use KeyDown events to check for keys being pressed

Presumably that's used once already in VBA....my issue is getting into VBA in the first place (hence the use of a hotkeys macro to trigger the VBA)
 

Users who are viewing this thread

Top Bottom