Temporarily disconnect then connect a USB port

rapsr59

Registered User.
Local time
Yesterday, 22:56
Joined
Dec 5, 2007
Messages
93
HI everyone!

I’ve developed a cash register system for my business.

An input device that is connected to a USB port scans the UPC codes, for products sold.

A second USB port has a keyboard connected for manual entry of the amount tendered at the completion of the sale.

As is, when the clerk opens the “Amount Tendered Form” to collect for, and finalize the sale, the UPC scanner remains on, and, if a product is accidentally scanned, the Amount Tendered Form interprets the code as the amount tendered. EX: $3,575,347.00. (Wow!)

My question is:

Can anyone tell me how to temporarily disconnect the USB port that the scanner is connected to during the finalization of the sale, so a product code cannot enter the system during the finalization of the sale, and re-connect the port after the sale is finalized?


Thank you for any ideas!


Richard
 
Hi

not sure if that would be the best thing to do in this scenario. You would be far better and more practical to leave the USB on because what if your sytem crashed whilst the USB was off? You would then need to constantly check for the USB to turn it on if it was off!

I would create a code to not accept anymore scanned data so even if a product did accidently get scanned, it didn't matter as the current transaction was closed. I'm not sure how your system works but a suggestion in laymans term would be-

scan the product for the transaction
click a button to finalise which blocks further scanning data being added
if additional items are the added, have a continue purchase button
otherwise
finalise transaction and reset the code to allow scanning again


All could be done with a simple public Boolean variable.
True = scan entry accepted
false = scan entry not accepted

hth

nigel
 
Hi You All!

Thank you for looking.

I’ve found a way to programmatically “Shunt the unwanted input to ground!” (Cancel the unwanted input from the scanner.)

Here’s how I did it.

The following example shows how input from a scanner and keyboard can be cancelled and only input from the “Keypad” is allowed.

In testing the scanner, the Keyboard numeric keys, and the Keypad numeric keys I found the following to be true.

When the keys 0 though 9 are depressed on the “Keyboard”, and when a product is scanned, the resultant values in the “KeyCode” variable in the “KeyDown event, and “KeyAscii” variable in the “Keypress” event are identical.

The values are 48 for 0 (zero) through 57 for 9, both in the KeyCode and Keypress variables.


When the keys 0 though 9 are depressed on the “Keypad”, the resultant values in the “KeyCode” variable in the “KeyDown event, and “KeyAscii” variable in the “Keypress” event are different.

The values are 96 for 0 (zero) in the “KeyCode” variable and 48 for 9 in the KeyAscii variable. The key “1” is 97 in the KeyCode variable and 49 in the KeyCode variable and so on… when using the numeric Keypad.


In the declarations section of the Forms code module, I defined a variable called “KeyPressed” as an integer.

Code:
[SIZE=3][COLOR=black][FONT=Times New Roman]Option Compare Database[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=black][FONT=Times New Roman]Option Explicit[/FONT][/COLOR][/SIZE]
 
[SIZE=3][COLOR=black][FONT=Times New Roman]Private KeyPressed As Integer[/FONT][/COLOR][/SIZE]

I then placed the following code in the controls’ KeyDown and KeyPress events, respectively.

Code:
[SIZE=3][COLOR=black][FONT=Times New Roman]Private Sub txtTest_KeyDown(KeyCode As Integer, Shift As Integer)[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=black][FONT=Times New Roman]   KeyPressed = KeyCode[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=black][FONT=Times New Roman]End Sub[/FONT][/COLOR][/SIZE]
 
[SIZE=3][COLOR=black][FONT=Times New Roman]Private Sub txtTest_KeyPress(KeyAscii As Integer)[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=black][FONT=Times New Roman]   ‘Cancel Key presses from the keyboard and scanned UPC codes[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=black][FONT=Times New Roman]   If KeyPressed = KeyAscii Then DoCmd.CancelEvent[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=black][FONT=Times New Roman]End Sub[/FONT][/COLOR][/SIZE]

The above is a "RAW" example of how to cancel any numeric key presses from the "Keyboard" but allow the entry of numeric key presses from the Keypad.

I do want to thank all of you for looking at this thread. Perhaps this technique can be used by you in the future. I certainly fixed my problem!

Richard
 

Users who are viewing this thread

Back
Top Bottom