number lock keeps going off (2 Viewers)

payfast

New member
Local time
Today, 02:16
Joined
Apr 19, 2016
Messages
8
i have some code that i need to run the sendkeys ({"esc}") on to clear out the drop down not in list.
It is a shared dropdown so client can type in drop down to find item (dog food, cat food etc.) or you can scan barcode into it and if not in list it goes to code below and picks up the barcode and puts the item into the invoice items to be paid for.

if i don't hit escape the dropdown stays open with the list of products and you have to click out of it to close. i've tried to move the focus but only thing works is the esc key that i could find. now not for all machines but some it seems to turn off the num lock on the computer after running the send keys so i used the send keys
Sendkeys ("{NUMLOCK}"), True to see if that will make sure it is on but doesn't work does anyone have a possible solution for this?


Code:
Private Sub sku_NotInList(NewData As String, Response As Integer)
DoCmd.SetWarnings False
On Error Resume Next
Response = acDataErrContinue

'Debug.Print NewData
If Me.handScanner = 1 Then
    NewData = Right(Left(NewData, Len(NewData) - 1), Len(Left(NewData, Len(NewData) - 1)) - 1)
Else
    NewData = Right(Left(NewData, Len(NewData)), Len(Left(NewData, Len(NewData))))
End If
 
[ProductNum] = DLookup("ItemID", "alias", "[Alias]='" & NewData & "'")
Me.sku = Null
Refresh

Dim probar
probar = DLookup("id", "productbar1")

Select Case True
Case Nz(probar, 0) = 0
  Dialog.Box "We can not find the item in the list please try again!" & vbNewLine & vbNewLine & _
             "If you still can't find your item it may have not scanned it in to the system " & _
             "correctly under (Barcode or UPC Code) in add edit products.", _
             vbCritical, "Error...Can't find item!"
  payfastbar
Case [OutStockBlock] = True, _
     Nz([Invx], 0) >= 1
  Forms!restaraunt.payfastbarx
Case Nz([Invx], 0) < 1 And Dialog.Box("You are out of Stock in your inventory do you want to add this anyways?", vbYesNo + vbCritical, "Please confirm:") = vbYes
  Forms!restaraunt.payfastbarx
End Select

Me.sku = Null

'Sendkeys ("{Enter}")
Pause 0.1
Sendkeys ("{esc}")
Sendkeys ("{NUMLOCK}"), True


invask



DoCmd.SetWarnings True
End Sub
 

Attachments

  • Screenshotpos.jpg
    Screenshotpos.jpg
    251.1 KB · Views: 13
Hi. I did a quick test, and it seems to me that acDataErrContinue will open the dropdown and acDataErrAdded will keep it closed. Just a thought...
 
I've experienced this when using sendkeys and never found a solution for it - but go with dbguy's solution if possible, sendkeys is unreliable and a terrible platform on which to rest any serious business process. For all you know, while your code is running, your user will open a window from their Accounting software and your Sendkeys will be sent into that application and pay someone a million dollar check - pretty much anything could happen using sendkeys, and often does
 
hi dbguy how would you implement it? i tried a couple options and all turned warnings back on getting not in the list popup and dropdown still popping down?
 
sorry not trying to add it to the list if it's not there when not there it searches the barcode table for the product and puts it in there and that works great however leaves the drop down dropped down, esc is only thing to keep it closed going to try to check numlock if false then make it true. see what that does thank you.
 
sorry not trying to add it to the list if it's not there when not there it searches the barcode table for the product and puts it in there and that works great however leaves the drop down dropped down, esc is only thing to keep it closed going to try to check numlock if false then make it true. see what that does thank you.
Well, when I said I did a quick test earlier, I didn't actually add to the list and found out that the dropdown doesn't show by using acDataErrAdded (without actually adding data). I didn't understand your requirement, so I made the demo that way, but you should be able to adapt it. If you want, I could try to modify it to add a record to a different table, is that what you meant?

Sent from phone...
 
Well, when I said I did a quick test earlier, I didn't actually add to the list and found out that the dropdown doesn't show by using acDataErrAdded (without actually adding data). I didn't understand your requirement, so I made the demo that way, but you should be able to adapt it. If you want, I could try to modify it to add a record to a different table, is that what you meant?

Sent from phone...
no i don't need it to add any records at all everything works great accept it turns off the number lock button i'm going to test a solution later when their no customers popping in and i will let you know thank you.
 
no i don't need it to add any records at all everything works great accept it turns off the number lock button i'm going to test a solution later when their no customers popping in and i will let you know thank you.
Ah okay, like I said earlier, my quick test didn't add any new items to the list, but the dropdown didn't show up, so there's no need to use Esc.
 
Sendkeys is the culprit. You should roll out your own Sendkeys, like:
Code:
Public Sub MySendKeys(Byval strString As String, Byval Option bolWait As Boolean =False)
With CreateObject("WScript.Shell")
    .SendKeys strString, bolWait
End With
End Sub

to use in your code replace:
Code:
Sendkeys ("{esc}")
Sendkeys ("{NUMLOCK}"), True

With:
Code:
MySendKeys "{ESC}"
 

Users who are viewing this thread

Back
Top Bottom