Prev: Apostrophe Problem
Next: coding between subforms
From: iccsi on 2 Jun 2010 11:44 I would like to set enabled to false, but sometimes the command button is on focus that I got error that I can not disabled controls when it is on focus. I wanted to check if it is on focus before disabled it, but I onlt find SetFocus method. Any property to read focus of the controls to check does the controls are in focus? Any information is great appreciated,
From: Douglas J. Steele on 2 Jun 2010 12:40 Screen.ActiveControl.Name will tell you which control has focus. -- Doug Steele, Microsoft Access MVP http://www.AccessMVP.com/DJSteele Co-author: Access 2010 Solutions, published by Wiley (no e-mails, please!) "iccsi" <inungh(a)gmail.com> wrote in message news:139372a5-00a0-4b8a-bab2-e1c0c1919f60(a)d12g2000vbr.googlegroups.com... >I would like to set enabled to false, but sometimes the command button > is on focus that I got error that I can not disabled controls when it > is on focus. > > I wanted to check if it is on focus before disabled it, but I onlt > find SetFocus method. > > Any property to read focus of the controls to check does the controls > are in focus? > > Any information is great appreciated,
From: Marshall Barton on 2 Jun 2010 13:37 iccsi wrote: >I would like to set enabled to false, but sometimes the command button >is on focus that I got error that I can not disabled controls when it >is on focus. > >I wanted to check if it is on focus before disabled it, but I onlt >find SetFocus method. > >Any property to read focus of the controls to check does the controls >are in focus? Since only one control on a form can have the focus, you can just check to see if the control is the active control. If Me.ActiveControl Is Me.somecontrol Then Me.somecontrol.Enabled = False End If But, if you are using a command button on the same form to disable itself, the command button is guaranteed to have the focus and that code will never disable the button. In this case you need to set the focus to another control before trying to disable the button. Maybe the control that had the focus before the button would be appropriate. If so, try using: Screen.PreviousControl.SetFocus Me.thebutton.Enabled = False OTOH, if you are using a button to disable some other control, you already know that the other control does not have the focus, So, all you need would be: Me.somecontrol.Enabled = False but you said that the control you want to disable "sometimes" has the focus. This implies that the code to disable the control is in a different form than the control so most of the above is irrelevant. -- Marsh MVP [MS Access]
|
Pages: 1 Prev: Apostrophe Problem Next: coding between subforms |