Command which closes any On screen active form (2 Viewers)

shahiq

Registered User.
Local time
Today, 10:54
Joined
Mar 31, 2007
Messages
29
Need some help on a command which would close any on screen active form. I want to have this Esc key enabled as an autokey to close any screen active form. I know how this autokey thing works but unable to figure out proper code.

thanks
 

boblarson

Smeghead
Local time
Today, 10:54
Joined
Jan 12, 2001
Messages
32,059
If you put a button on the form that closes it with:

DoCmd.Close acForm, Me.Name, acSaveNo

And set the button's Cancel Property (on the Other Tab in the properties dialog) to YES then if someone hits the escape key it will act as if pressing that button.
 

shahiq

Registered User.
Local time
Today, 10:54
Joined
Mar 31, 2007
Messages
29
If you put a button on the form that closes it with:

DoCmd.Close acForm, Me.Name, acSaveNo

And set the button's Cancel Property (on the Other Tab in the properties dialog) to YES then if someone hits the escape key it will act as if pressing that button.

thanks dude.......I want to save the record before closing...... how would it do...

thanks
 

boblarson

Smeghead
Local time
Today, 10:54
Joined
Jan 12, 2001
Messages
32,059
If the form is bound, it will save automatically when you close (the acSaveNo means design changes to the form, not to the record).
 

shahiq

Registered User.
Local time
Today, 10:54
Joined
Mar 31, 2007
Messages
29
If the form is bound, it will save automatically when you close (the acSaveNo means design changes to the form, not to the record).

Thank you for your prompt reply dude........

It doesnt seem to be saving.... Esc thing is perfectly working but it doesnt save. when I click that button anc close it saves record. But when I hit Esc key and close it doesnt save the record

And also any idea which I can have this Button thing Invisible. when I try Visible =No on property dialog box the command doesnt work.

thanks
 

boblarson

Smeghead
Local time
Today, 10:54
Joined
Jan 12, 2001
Messages
32,059
You can always include

DoCmd.RunCommand acCmdSaveRecord

to explicitly save the record.

The button has to be visible to be used, but it should be able to be set so you can't see it. Try setting the measurements to something like .01" width and .01" Height.
 

shahiq

Registered User.
Local time
Today, 10:54
Joined
Mar 31, 2007
Messages
29
You can always include

DoCmd.RunCommand acCmdSaveRecord

to explicitly save the record.

The button has to be visible to be used, but it should be able to be set so you can't see it. Try setting the measurements to something like .01" width and .01" Height.

thanks dude

its perfect now.........
 

Users who are viewing this thread

Top Bottom