Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting focus to Main form when inserting new record 1

Status
Not open for further replies.

njitter

Technical User
Sep 4, 2001
122
US
Hello,

Main form : Form_Guidelines_Main
Linked Sub form : Form_Guidelines_Sub

I would like to move the cursor (setfocus) to the control called Guidance on the Main form when i insert a new record.

Any hints??

Njit

---
It's never too late to do the Right thing
 
When you click on new record the cursor will land on a field that is first in the tab order.

You can also do the following as well on the form's current event property using the following code:

Me.Guidance.SetFocus

Hope this helps.

:)WB
 
WB,

the above is NOT true..

When i browse through the form the focus stays on the current control (does not matter if i'm on the main or or the subform).

Me.Guidance.SetFocus does not work (already tried this).

Njit

---
It's never too late to do the Right thing
 
Hi

"does not work " is not very helpful

What happens, any error message(s) ?

Where are you running the setfocus code?

Is the control .guidance on the main form?

If yes and you are running your setfocus code in the subform, try

parent.guidance.setfocus

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
KenReay,

i tried the Me.Guidance.Setfocus in the BeforeInsert event on the Main form.

Njit

---
It's never too late to do the Right thing
 
Hi

And?, what happened, error message(s)

Is the Control Guidance on the main form?

is the record inserted into the main form dataset or the sub form dataset?


Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Here are couple of more questions that might help us to help you better:

1. In your post you say "when I insert a new record" but in you reply to my post you say "When i browse through the form the focus stays on the current control (does not matter if i'm on the main or or the subform)."

2. What do you mean by browse? Are you talking about going from one record to the other or from subform to the main form? Keep in mind you must do something on the form and then throw the focus to a field after doing such action.

3. What is name of the current control that it stays on?

What I have sugguested does work but I think the problem here is that we don't have enough/right information to get you from point A to point B.

Let us know,





:)WB
 
Should it be Me.Guidance.Setfocus or Me!Guidance.Setfocus ?

As a matter of convention I use the ! for referring to fields to avoid confusion or the index method
Me("Guidance").SetFocus
 
Because 1 image is worth 1000 words: (90 kb)

What i would like to accomplish:

when i scroll through the records with the record selector on the main form i would like the focus to jump to the Guidance field when a new record is created no matter what field i'm currently on.

Currently the focus stays on the currently selected field (main form or subform) when a new record is created.



---
It's never too late to do the Right thing
 
KenReay,

works like a charm - case closed.

ps, image did the trick i guess :)

---
It's never too late to do the Right thing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top