PDA

View Full Version : MS Access VBA - Disable object while on focus



Ronald_yoh
05-27-2008, 06:27 PM
Does anyone know how to disable the object in MS Access via VBA while the object is on focus.

Suppose you have a "save" button, when you click the button and at the end of the execution line (before exit sub), you want to disable the "save" button.

I got an error of doing the above since the object is still on focus.

Any thoughts???

Thanks
R

Carl A
05-27-2008, 07:48 PM
Set Focus to another control just before you disable the Save Button

Ronald_yoh
05-28-2008, 03:48 PM
mate.. ur comment seriously not helping at all!!!

Carl A
05-28-2008, 04:38 PM
Suppose you have a "save" button, when you click the button and at the end of the execution line (before exit sub), you want to disable the "save" button.

Private Sub cmdSave_Click()
cmdOK.SetFocus 'or another control
cmdSave.Enabled = False
End Sub

Ronald_yoh
06-01-2008, 10:25 PM
I had tried the logic but it never passes the focus to another control/object.

Any other solutions, mate?

Cheers
R

Carl A
06-02-2008, 03:35 AM
AFAIK there isn't any other way to disable a control in access as long as it has the focus. There are alot of other resources on the net that will tell you the same thing.
Here is a working example.