Set Focus On Subform Control

S

Scientific

Hello all,

How do you set focus on a subform control using VB. I keep getting errors
with the following format:

Me.SubFormName.SubFormControlName.SetFocus

I get this error:

"Object doesn't support this property or method"

-S
 
S

Stuart McCall

Scientific said:
Hello all,

How do you set focus on a subform control using VB. I keep getting errors
with the following format:

Me.SubFormName.SubFormControlName.SetFocus

I get this error:

"Object doesn't support this property or method"

-S

Just use:

Me.SubFormControlName.SetFocus
 
J

John W. Vinson

Hello all,

How do you set focus on a subform control using VB. I keep getting errors
with the following format:

Me.SubFormName.SubFormControlName.SetFocus

I get this error:

"Object doesn't support this property or method"

-S

It's odd... you need to do two setfocus commands in succession:

Me!SubFormName.SetFocus
Me!SubFormName.Form!SubFormControlName.SetFocus
 
R

Rod Plastow

I assume your VBA code is that of the parent form.

What you must do is first refer to the parent form control that contains the
subform, then the subform, then the subform control and finally the method.

A generic example will probably help:

Me.ControlP.Form.ControlS.SetFocus

where ControlP is the name of the control on the parent form and ControlS is
the name of the control on the subform that you wish to have the focus.

Another way of doing this is:

Dim MySubForm as Access.Form (or even as Form_.........)
Set MyForm = Me.ControlP.Form
MyForm.ControlS.SetFocus

The confusion arises because Access defaults to naming the container control
on the parent form with the name of the form it contains - same name for two
different things.

Rod
 
S

Scientific

Stuart,

Guess I should have mentioned I'm using the Tool Tips code by Stephan Lebans
and it seems to require focus set on a control, but it won't work if focus is
set on subform control. I noticed it was originally written for Access 97 so
I think I should see if there's an updated version which may address this
issue.

Thanks for quick reply though Stuart. Will post back if situation gets
resolved :)

-S
 
S

Stuart McCall

Scientific said:
Stuart,

Guess I should have mentioned I'm using the Tool Tips code by Stephan
Lebans
and it seems to require focus set on a control, but it won't work if focus
is
set on subform control. I noticed it was originally written for Access 97
so
I think I should see if there's an updated version which may address this
issue.

Thanks for quick reply though Stuart. Will post back if situation gets
resolved :)

-S

Ah, in that case take John or Rod's advice (even though they don't answer
your original question). That ought to clear your problem.

If the control you set focus to must be on the main form though, you could
always use a 'dummy' control, either sized 0, 0 or placed in the Page Footer
section (which never appears on screen).

HTH
 

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