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

Subform - setting focus to a record

Status
Not open for further replies.

DaveTappenden

Programmer
Jan 16, 2002
21
I have a simple 'stock' form and subform. The main form shows the stock record and the subform shows matching batch numbers for that stock record. The form is based on a query, the query itself being created from a search form, where the user can search for stock records OR batch numbers.
Everything works fine with the search, if a user enters a batch number in the search form, my code creates the query and opens the stock form/subform based on that query.
My question is:
If a user searches by batch number, can I make the subform (which is datasheet format) get the focus of this row?
At present, is a user searches for, example batch 456, then the correct stock record is displayed that contains that batch number, but the user has to scroll down to find it in the subform. Even better, would be for some code to highlight the datasheet record that has the focus.

Hope I have made myself clear
 
Try this:
In on load event of the stock form

DoCmd.gotocontrol "SubFormControlName"
docmd.gotocontrol "TextBoxNameInWhichToSearch" 'in subform
docmd.findrecord TextBoxOnMainFormWithBatchNum
docmd.runcommand acCmdSelectRecord

Hope this helps
Mangro
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top