Send Escape Key

Djblois

Registered User.
Local time
Today, 08:58
Joined
Jan 26, 2009
Messages
598
Is this the correct code for sending an Escape key to code?

SendKeys "{ESC}"

It doesn't do anything even though the escape key does what I want?
 
Send keys doesn't work in newer versions of Windows, use Me.Undo in vba instead
 
Never use send keys, to unpredictable if the user gets the focus to another app while your code is running.
 
The undo command does not do what I need but the escape key does. Are there other options? I am trying to get it to clear a line if it ends up being a duplicate Primary key. I use the Order Number as the Primary key that someone will pull from another program.
 
You cannot duplicate a primary key field if you have it setup correctly. You can use a DCount or DLookup to check if a number has already been used in that fields before update event to prevent duplicates if the user is typing the number in.
 
I have it setup to not allow duplicates no problem. However, I have code that will pop up an Error screen that will say it was added already and I want to clear it from the form. The only way I have found to clear it from the form is the escape key. Here is the code:

Code:
Forms!frmScheduled_Appts!subfrmRecOrders!tbOrderNum.Value = ""
Forms!frmScheduled_Appts!subfrmRecOrders!cobStorer.Value = ""
        
DoCmd.OpenForm "frmErrorOrder", , , "Appt_Id = " & DLookup("[Appt_id]", strTable, "[REF] = '" & strOrderNum & "'")
Forms!frmErrorOrder.lblError.Caption = "Order#" & strOrderNum & _
" has already been entered. It is already attached to this Appointment:"
Response = acDataErrContinue
 

Users who are viewing this thread

Back
Top Bottom