Sendkeys "{ESC}" closes open form.

  • Thread starter Thread starter cool_archie
  • Start date Start date
C

cool_archie

Guest
Hello,

Sendkeys "{ESC}" closes open form.
Need Solution to use sendkeys "{ESC}" and keep the form open!

Regards,
Archie
 
This is not a good way to close a form. Use

Code:
Docmd.Close acForm, me.Name

If you want to cancel on the form unload event place:

Code:
If MsgBox("Close Form?", vbOKCancel, "Close Form?") = vbCancel Then
Cancel = True
End If[code]
 
Archie,

If you don't delete your other duplicate threads... never expect an answer from me. In my opinion posting multiple times demonstrates ignorance and not urgency - and ignorance upsets me. Please go back and do your part in cleaning up the forum.

Modest
 
Well I really dont know how this message got posted so many times.

Neways I have deleted the duplicate messages.
 
dt01pqt said:
This is not a good way to close a form. Use

Code:
Docmd.Close acForm, me.Name

If you want to cancel on the form unload event place:

Code:
If MsgBox("Close Form?", vbOKCancel, "Close Form?") = vbCancel Then
Cancel = True
End If[code][/QUOTE]


Well I am not closing the form using Sendkeys...
I am using it to undo a value entered in a field once the user cancels instead of saving, I am using Sendkeys.. instead of me.undo cause sendkeys restores the previous data in a field while keeping focus on the feild, whereas me.undo doesn't so i want a solution to do what I just mentioned above.

Regards,
Archie
 
SendKeys is not the way to go. You should avoid using the SendKeys.

Check the Access help files [or search here] on how to use the .OldValue property.
 
cool_archie said:
Well I really dont know how this message got posted so many times.

Neways I have deleted the duplicate messages.

Thank you :) -- I'll proceed to look at your problem.

I agree with Hudson, Sendkeys isn't just not a good way.. it's fickle. Let me look through my database for something I did before.
 
Last edited:
I'm not sure if it restores what was previsouly there, but I just created a "Cancel" button and use the following code with it:

DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70

Try overriding your {ESC} preset with it.

-Modest
 
Last edited:
modest said:
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
-Modest
Outdated menu command option. :eek: Use the DoCmd.RunCommand's instead.

Code:
DoCmd.RunCommand acCmdUndo
The .OldValue property will allow you to return the specified fields value to what it originally was for a bound form. I use it often in the AfterUpdate event of a combo box. I ask if the user "if" they meant to change the combo box value of an old record. This prevents the user from editing an old record when they should have started a new record and then selected a value in a combo box.
 
ghudson said:
Outdated menu command option. :eek:

"Let me look through my database for something I did before." ... I just didn't say how long ago I did it :) By the way RunCommand still pulls from the menu. It's just the new way of doing it.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom