Disable button

  • Thread starter Thread starter MN
  • Start date Start date
M

MN

Access2K. i have a form, when user finished enter data and click SAVE button.
I want after that the button is disable. How can I do that?
Thank you in advance.
MN
 
MN said:
Access2K. i have a form, when user finished enter data and click SAVE
button.
I want after that the button is disable. How can I do that?
Thank you in advance.
MN

First you must move the input focus away from the button, because you can't
disable it while it has focus. Do this by using the SetFocus method of some
other control on the form:

Me.ControlName.SetFocus

Then, once that step is done, you can disable the button

Me.SAVE.Enabled = False
 
In the afterupdate event of the form set the Enabled property of the button
to false...

Private Sub Form_AfterUpdate()
Me.ButtonName.Enabled = False
End Sub

this is one way, but then you need to reset it for each record you go to
(use the Current event of the form) or when the form is Dirty... etc.

Setting the enabled property is easy, but finding all the required places to
put the line of code to make it work as you like can be a bit troublesome.

FYI, for my Save button, I tried to do this and settled for just leaving the
thing enabled all the time.

hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
Thank you for your info.
When I tried it, I got an error: "Runtime error 2164 - You can't disable
control while it has the focus".
BTW-how can I set the form is Dirty ?
Thank you.
 
Back
Top