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

moving to new record in subform

Status
Not open for further replies.

jossung

Programmer
Sep 26, 2001
9
US
Hi All,

I'm writing a dbase for a local garage. In my app I have a Parts subform within a Work Order form. On the Work Order, there's commandbutton that calls a third form that allows the user to search for parts then transfer the desired part to the Parts subform. I'd like it if the commandbutton also moved the focus in the Parts subform to a new record, but I'm not having much luck. Any help would be appreciated.
I already know about DoCmd.RunCommand acCmdDataEntry. But how do I get it to apply to the subform?

Thanks in advance.
 
You need to first set the focus to the subform and then advance the record pointer to a new record:

Forms!WorkOrder!PartsSubform.SetFocus
DoCmd.GoToRecord , , acNewRec

But better yet after a user selects a part why not just run an append query to add it to the table that displays the parts subform and then update the parts subform display to show the part selected? This avoids having to type in the data that's already displayed.

DoCmd.SetWarnings False
DoCmd.OpenQuery "AppendPartToWorkOrder"
DoCmd.SetWarnings True
Forms!WorkOrder!PartsSubform.SetFocus
Forms!WorkOrder!PartsSubform.Requery

Of course, the query needs to add all the relevant data to the subform and/or work order. You may also need to adjust inventory at the same time and/or pricing of the work order. Sounds like a fun project.

Uncle Jack

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top