setfocus vs hasfocus

ClaraBarton

Registered User.
Local time
, 22:34
Joined
Oct 14, 2019
Messages
574
When I Setfocus to a field from vba, the Hasfocus on conditional formatting doesn't consistently kick in. Is there a way to do this differently?
 
You could try to change the formatting with code as well. What sorts of formatting were you doing? Are you using a continuous form?
 
I just want it highlighted to show it's the focus. Conditional formatting works well for all the fields when entering except that first setfocus. And sometimes it works....??!! Mostly doesn't.
 
Last edited:
Presume you mean a control, not a field?

Is the field or setfocus code on a subform? If so, assuming it is the control on a subform you need to setfocus to the subform before setting focus to the control
 
the field (control, sorry) has the focus. The blinker's in it. It just doesn't immediately highlight. It's actually a sub sub sub form but it is there.
 
When I Setfocus to a field from vba, the Hasfocus on conditional formatting doesn't consistently kick in. Is there a way to do this differently?
When you reference a control from VBA, the control's events do not fire. If you want an event to fire, you must call it specifically.
 
You are probably best having code in each controls event to highlight the control in the way you want, and deactivate the previous control. it won't do it the way you would like in a continuous form though.
 
Conditional formatting works well for all the fields when entering except that first setfocus. And sometimes it works....??!! Mostly doesn't.
it always work for me. check again your CF.
 

Users who are viewing this thread

Back
Top Bottom