Jim Horn
asked on
Must ... lose ... focus...
Access subform, with a bunch of controls, and a label the size of the whole subform that says 'No records found.'
If Form.Open VBA code determines that there is a record, makes label.visible = false, all other controls.visible = true
If Form.Open VBA code determines that there is no record, makes label.visible = true, all other controls.visible = false
Problem is, one control will always have the focus, so in my quest to make all other controls.visible = false, one must have the focus, therefore will always be active.
Question: How do you set a form such that no control control that can have the focus, has the focus?
TIA
-Jim
If Form.Open VBA code determines that there is a record, makes label.visible = false, all other controls.visible = true
If Form.Open VBA code determines that there is no record, makes label.visible = true, all other controls.visible = false
Problem is, one control will always have the focus, so in my quest to make all other controls.visible = false, one must have the focus, therefore will always be active.
Question: How do you set a form such that no control control that can have the focus, has the focus?
TIA
-Jim
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Create a button that is flat, no border, no text (or at least set forecolour to the same as the form) and no code behind it. Have the focus on that by default (Tab Stop 0). Then you will always have a control that can have focus.'
ummmm
If whatever Then
Me.Label2.BackStyle = Transparent
Me.Label2.Caption = ""
Else
Me.Label2.BackStyle = normal
Me.Label2.Caption = "Nope...no records"
End If
If whatever Then
Me.Label2.BackStyle = Transparent
Me.Label2.Caption = ""
Else
Me.Label2.BackStyle = normal
Me.Label2.Caption = "Nope...no records"
End If
ASKER
MX - Worked like a charm. Thanks. -JHo
wow ... great. cool.
As I mentioned ... I basically never have to worry about disabling a control (command button typically) ... I just set focus to that focus hold control first ...
I named it zztxtFocusHold ... so it sorts at the bottom of the controls list on the tool bar :-)
thanks Jim ...
mx
As I mentioned ... I basically never have to worry about disabling a control (command button typically) ... I just set focus to that focus hold control first ...
I named it zztxtFocusHold ... so it sorts at the bottom of the controls list on the tool bar :-)
thanks Jim ...
mx
mine was cooler :o)
mine is more versatile and flexible and generic ... and works with tuna also.
mx
mx
zzTxtFocusHold.SetFocus ...
mx