UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> SendKeys function in form text field    
 
   
zorki
post Jul 16 2006, 05:54 AM
Post #1

UtterAccess Enthusiast
Posts: 53
From: Poland



Hi everybody,

I am looking for help, explanation of function SendKeys.

In my form I have text box in which I put an event, 'before update' like below:

Sub Form_beforeupdate(cancel as integer)
cancel = 1
sendkeys "{ESC}"
end sub


Pressing ESC key in above function should cause that eventual change in text box will not be accepted and changes will be undo. Unfortunately ESC key is not pressed and I need to do it manually from keyboard.

What is wrong? Can anybody help me how to resolve this problem?

Regards,
Go to the top of the page
 
+
dannyseager
post Jul 16 2006, 08:33 AM
Post #2

UtterAccess VIP
Posts: 13,031
From: Leicester, UK



Firstly I (and many others) will advise you to avoid sendkeys. They can be unreliable and dangerous if the right window/form/control doesn't have focus....

The code you posted will simple not allow the user input to be saved as you cancel the update of the control with cancel=1... what are you trying to accomplish?
Go to the top of the page
 
+
zorki
post Jul 16 2006, 11:38 AM
Post #3

UtterAccess Enthusiast
Posts: 53
From: Poland



Thanks for reply,

Formula cancel=1 will not allow the user to make changes, but will not undo changes automatically. User will see error message and will have to press ESC. If he try to pas it over by closing form an error message will appear again and of course changes will be not saved.
However I want to avoid presenting error messages and making pressing ESC automatic.
Go to the top of the page
 
+
dannyseager
post Jul 16 2006, 12:26 PM
Post #4

UtterAccess VIP
Posts: 13,031
From: Leicester, UK



try

Cancel = True
Me.ControlName.Undo
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 20th May 2013 - 04:27 PM