Setting Focus in a Tab Form

Raymondo

New member
Local time
Today, 06:24
Joined
Jun 11, 2001
Messages
5
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?
 
you need to set focus to the page first, then the control
 
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!
 
Your syntax looks a bit strange.
To refer a control ona subform ,from a main form:
Me!Subform1.Form!ControlNameMe!Subform1.Form!ControlName

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
 
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
 
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
 
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
 

Users who are viewing this thread

Back
Top Bottom