Link to home
Start Free TrialLog in
Avatar of Jim Horn
Jim HornFlag for United States of America

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
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OH ... in the form OnOpen ...

zzTxtFocusHold.SetFocus ...

mx
Avatar of Atropa
Atropa

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
Avatar of Jim Horn

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
mine was cooler :o)
mine is more versatile and flexible and generic ... and works with tuna also.

mx