acramer_dominium
asked on
Can't Hide a Control that has Focus
Experts. I have a program where I am trying to hide all controls if an argument is met. The argument is met, I'm hiding all controls and I'm getting the error you can't hide a control that has focus (Source (textbox) ).
Just above this statement of hiding the control, I have the program setting focus to the close button. Seems to be ignoring the fact that I've set focus to the close button. txtSource never gets focus and is item 41 in tab control so I don't see how it's getting focus.
Any ideas?
If MarketType = 0 Or (MarketType = 1 And HomeCount = 0) Then
Forms!frmLookUpIGL.Form.cm dClose.Set Focus
'First Source Box: Hide
Me.lblSource.Visible = False
Me.Source1Box.Visible = False
Me.Source.Visible = False
Just above this statement of hiding the control, I have the program setting focus to the close button. Seems to be ignoring the fact that I've set focus to the close button. txtSource never gets focus and is item 41 in tab control so I don't see how it's getting focus.
Any ideas?
If MarketType = 0 Or (MarketType = 1 And HomeCount = 0) Then
Forms!frmLookUpIGL.Form.cm
'First Source Box: Hide
Me.lblSource.Visible = False
Me.Source1Box.Visible = False
Me.Source.Visible = False
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This:
Forms!frmLookUpIGL.Form.cm dClose.Set Focus
Should be:
Forms!frmLookUpIGL!cmdClos e.SetFocus
Assuming this is a single or parent form and the close button is on it, and frmLookup is the actual name of the form.
And if this code is running in that form, you can simply do:
Me.cmdClose.SetFocus
Jim.
Forms!frmLookUpIGL.Form.cm
Should be:
Forms!frmLookUpIGL!cmdClos
Assuming this is a single or parent form and the close button is on it, and frmLookup is the actual name of the form.
And if this code is running in that form, you can simply do:
Me.cmdClose.SetFocus
Jim.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This worked. I added an unbound text box on the form and set focus to that. I'm just going to make it blend in with the background. Thank you for the suggestions! I've never had this happen before.
Welcome!
Me.SetFocus