Check status before focus

M

MrX

How can I check the status (visible or hidden) of a field before apply
the setfocus on that field ?
I've now a setfocus on a field that could be hidden. If hidden I want
to set the focus on another field.
Hope somebody can help me with this. Thanks in advance !
 
F

fredg

How can I check the status (visible or hidden) of a field before apply
the setfocus on that field ?
I've now a setfocus on a field that could be hidden. If hidden I want
to set the focus on another field.
Hope somebody can help me with this. Thanks in advance !

Why does it matter for you to know in advance?
Use error handling.

On Error GoTo ErrorHandler

Me.[ControlName].SetFocus

Exit_Sub:
Exit Sub
ErrorHandler:
If err = 2110 Then
Me.[SomeOtherControl].SetFocus
End If
Resume Exit_Sub
 
M

Marshall Barton

MrX said:
How can I check the status (visible or hidden) of a field before apply
the setfocus on that field ?
I've now a setfocus on a field that could be hidden. If hidden I want
to set the focus on another field.


I assume you mean control, not field. But even then,
controls on a report do not get the focus so the question is
moot.

On a form, you can just check the control's Visible
property:

If Me.somecontrol.Visible Then
Me.somecontrol.SetFocus
Else
? ? ?
End If
 
M

MrX

Thanks ! It's working now.
And it was stupid off me to post this in the report section, I needed
it for a form.
But thanks for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top