View Full Version : Setting Focus in a Tab Form


Raymondo
09-14-2001, 03:40 AM
I'm trying to set the focus to a control in a sub form on a Tab form. I have tried using the event procedure when OnClick of a tab to set the focus but it does not work. The code I have used in the event procedure is as follows:

[Subform].setfocus
[Subform]![Control].setfocus

I am using Access 97 - can anyone help?

charityg
09-18-2001, 05:51 AM
you need to set focus to the page first, then the control

Raymondo
09-18-2001, 06:33 AM
Thanks charityg for replying

I have tried setting the focus to the page and then the control but can't get it to work. The focus still stays where is was left.

Any ideas!

Alexandre
09-18-2001, 10:09 AM
Your syntax looks a bit strange.
To refer a control ona subform ,from a main form:
Me!Subform1.Form!ControlNameMe!Subform1.Form!Contr olName

As far as I remember, there is no need to change the syntax when using a Tab control. It is considered as a control of your form, just like the others.

Alex

Raymondo
09-19-2001, 01:58 AM
Alex,

I have tried every combination I can think of it still does not work. The syntax works on other subforms I have (that are not in tab controls).

I think I'm going to have to live with it!

Thanks for your help

Ray

Alexandre
09-20-2001, 01:21 AM
I checked a database where I use control tabs. As I said, it works perfectly well without naming the tab page where the control is.
However, if you want to make sure, try the following

Me.ctlTabName.Page("PageName").Controls.Item("ControlName")

Where =
-ctlTabName is the name of your Tab
-PageName the name of the Tab page where your control is
-ControlName then name of the control you want to reach

Using the above syntax, each time you type a dot, ACCESS must make suggestions for the next step. If it doesn t it means that you made an error in the last step. This should help you understand where the problem comes from.

Alex

Raymondo
09-24-2001, 05:01 AM
Alex,

Sorry it's taken me a while to get back to you, our system had been affected by the Nimda virus - very nasty.

I have discovered that using an event procedure Onclick doesn't work. So I have used an event procedure OnEnter (on the subform in the tab control) and it works!!!

Thank you very much for all your help and for not giving up on me.

Ray