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

Navigation button event

Status
Not open for further replies.

raymondo

Technical User
May 3, 2002
86
0
0
AU
I was wondering if there is an event that is triggered each time the user presses one of the Nav buttons to move through the records in a form?
I have a form with 3 subforms, each on a different page of a tab control. Basically, what I want to do is:
if any of the fields in any one of the subforms has the focus and the user presses one of the nav buttons, which are only displayed for the main form by the way, the focus is to be given to a particular field in the main form.
Any suggestions?
 
Use the On_Current Event of the subform... it will let you know when a user has moved to a different record. In the On_Current Event, you can set the focus to a control on the main form. Assuming that your parent form is named frmParent, and the control you want to set focus to is txtOrderNumber you could use code like this:

Private Sub Form_Current()
Forms!frmMain!txtOrderNumber.SetFocus
End Sub

This will work, but I've got to tell you that it may be confusing to users. Every time they try to scroll through the records on a subform, they are going to have the focus shifted to the main form. That is not behavior that is expected, and for that reason, it is frowned upon. It is no more logical than putting a routine in the Unload Event of a form that launches an mp3 player and plays the theme to 'Shaft'. You can do it, but if people aren't expecting it, they'll be confused.

Rock ON!

Kevin
 
Thanks Kevin,
Actually the only nav buttons available to the users are on the main form so the shifting of focus shouldn't cause any confusion.
I want to do it so that if they by chance navigate to beyond the end of the record list in the main form, where you would normally add a new record, the user will be in the right place as the details in the main form MUST be completed before they attempt to enter things into the subform.
I'm wondering whether I may yet be forced to have some kind of check in every field on the subform! What a drag if that turns out to be the case.
Anyway, thanks again.
Raymondo
 
Raymondo,

You’re over complicating the issue. Once your user changes the focus from the subform to the mainform, Access is going to update the subforms’ underlying record source. If you want to insure the main form is properly completed before the subform is used/updated etc, use the before update event of the main form and check that all data has been properly manipulated.

Remember, when you move from the main form to the subform, the main form will fire an update so your main forms before update event will fire before focus gets to the subform Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top