AshikHusein
Registered User.
- Local time
- Today, 09:50
- Joined
- Feb 7, 2003
- Messages
- 147
Is there any way of sending an escape key (Esc) on the close event of a form using VBA?
I have a problem that when the form closes if somebody accidentally closes Access, that the entries on the form get saved when they are not supposed to be saved.
I have actually done this through macros by using the sendkey method using the docmd object but this does not seem to be working on the close event of the form.
The code on close event of the form is as follows: (part of it)
If IsNull(IPO_name_str) Then
[acct_num].SetFocus
[acct_num].Value = Null
DoCmd.RunMacro "mcr_send_2_keys_esc" <- Does not work
Else
Set recset = db.OpenRecordset("SELECT * FROM tbl_init_IPO_entry_details WHERE tbl_init_IPO_entry_details.IPO_name = """ & _
IPO_name_str & """", dbOpenDynaset)
recset.Edit
recset("dummy1") = Null
recset.Update
recset.Close
Set recset = Nothing
[acct_num].SetFocus
[acct_num].Value = Null
[IPO_name].Locked = False
DoCmd.RunMacro "mcr_send_2_keys_esc" <- Does not work
End If
All code seems to be working except DoCmd.RunMacro "mcr_send_2_keys_esc"
Would appreciate help fo the above.
I have a problem that when the form closes if somebody accidentally closes Access, that the entries on the form get saved when they are not supposed to be saved.
I have actually done this through macros by using the sendkey method using the docmd object but this does not seem to be working on the close event of the form.
The code on close event of the form is as follows: (part of it)
If IsNull(IPO_name_str) Then
[acct_num].SetFocus
[acct_num].Value = Null
DoCmd.RunMacro "mcr_send_2_keys_esc" <- Does not work
Else
Set recset = db.OpenRecordset("SELECT * FROM tbl_init_IPO_entry_details WHERE tbl_init_IPO_entry_details.IPO_name = """ & _
IPO_name_str & """", dbOpenDynaset)
recset.Edit
recset("dummy1") = Null
recset.Update
recset.Close
Set recset = Nothing
[acct_num].SetFocus
[acct_num].Value = Null
[IPO_name].Locked = False
DoCmd.RunMacro "mcr_send_2_keys_esc" <- Does not work
End If
All code seems to be working except DoCmd.RunMacro "mcr_send_2_keys_esc"
Would appreciate help fo the above.