By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,790 Members | 1,409 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,790 IT Pros & Developers. It's quick & easy.

Set focus to a particular field on a subform

P: 46
Hello,

Suppose I have a form (call it "form1") with two tabs. On tab1 I have a button that I would like to set the focus on a text box, call it "txt1" on a subform (call it "subform1") which is on the second tab, call it tab2.

[forms]![form1]![tab2]![subform1]![txt1].setfocus doesn't seem to be working. Any suggestions? Thank you!
Jan 9 '08 #1
Share this Question
Share on Google+
5 Replies


Rabbit
Expert Mod 10K+
P: 12,357
Hello,

Suppose I have a form (call it "form1") with two tabs. On tab1 I have a button that I would like to set the focus on a text box, call it "txt1" on a subform (call it "subform1") which is on the second tab, call it tab2.

[forms]![form1]![tab2]![subform1]![txt1].setfocus doesn't seem to be working. Any suggestions? Thank you!
Expand|Select|Wrap|Line Numbers
  1. Me.subform1.Form.txt1.SetFocus
Jan 9 '08 #2

P: 46
Thank you for the reply, but I notice that "subform1" does not autofill after typing "me.". As such, when I try to run this command it says the object is not found. Is this because it's on the separate tab? If so, how can I remedy this?
Jan 9 '08 #3

Rabbit
Expert Mod 10K+
P: 12,357
No, you don't need to refer to the tab when referring to controls on a tab. It should autofill assuming that the function is in the form's code module and that subform1 is the name of the subform control, not the name of the subform. They are separate things.
Jan 9 '08 #4

P: 46
Thank you.

To simplify, suppose I have a form (Form1) with two tabs (Tab1, Tab2). On both tabs there are subforms. Upon double-clicking of a certain field on Tab1 (within the subform), I'd like Tab2 to be selected, and the focus set to a certain field, call it 'Tab2Field.' What would be the code behind this?
Jan 18 '08 #5

Rabbit
Expert Mod 10K+
P: 12,357
You would use:
Expand|Select|Wrap|Line Numbers
  1. Me.Parent.FieldName
  2.  
Like I said earlier, you don't need to reference the tab name when referring to the controls on that tab. Just ignore what tab it's on.
Jan 18 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.