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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A set focus question 1

Status
Not open for further replies.

TerryEA

Technical User
Jun 20, 2004
99
GB
Hi all

I have an Orders Form and an Order Items sub form. I have "Add" command buttons in both so that the user can add a new order, or add a new item to an existing order. On the sub form I can obviously put code in the On Click event of the button to set the focus to a particular field, to make that the first field when adding a new item. This works OK.

Code: Me![Stock_Code].Setfocus

However, when the user enters data in an item in the subform, he may not fill out all the fields at that time and may stop at, say, field no 6 in the tab order. If he then goes to "Add a new Order", enters main form data data and then tabs to the subform to enter item data the focus is where the user last stopped. I don't seem to be able to set the focus back to the first field in these circumstances.

I've tried the On Current, On Activate and On Got Focus events of the subform, and used the same code as I used in the Add button (which does work) but it doesn't reset the focus.

Which event should I use? or is there another way?

Terry
 
How are ya TerryEA . . .

In the [blue]On Enter[/blue] event of the subform control:
Code:
[blue]   [[purple][b][i]subFormName[/i][/b][/purple]].Form!Stock_Code.SetFocus[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Hi TheAceMan1

Yeh, that did it. Cheers mate.

Terry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top