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

how to find a record in a subform

Status
Not open for further replies.

BOBOGLEY

Programmer
Aug 9, 2001
1
0
0
GB
By using a textbox to input a parameter,I want to click on a button that searches on a subform for a record that matches the input box parameter. Once it has found the record then the record needs to be highlighted or focused or indicated out of the full range of records on display in the subform. The subform is attached to a view.
Using Access 2000 with SQL server tables.
 
Instead, why not use a combo box instead of a text box?

The auto-complete feature will help users find exactly what they want and faster. In the After_Update event of the combo box, call a public function in the subform that goes to that record.

Gary
gwinn7
 
Here is an article that may also provide some insight in locating a record using a combo box (even with a subform).

Microsoft Knowledge Base
Q100132

Gary
gwinn7
 
How do you go to the record in the subform?
I understand what you're saying about the combo_box's auto-complete feature, but how do you code the search into that public function?

Also, where do I find Microsoft Knowledge Base?

Thanks!
 
One way of doing it is this...

In the AfterUpdate event of the combo box, you may insert something like the code below....

Dim rc as RecordSet
Set rc = Me.Subform.Form.RecordSetClone
rc.FindFirst "[RecordID] = " & Me.cboValue
Me.Subform.Form.Bookmark = rc.Bookmark
Set rc = nothing

PS. Be sure to set the property 'Limit To List' for the combo box. If you don't you will need to check the value of item selected or it will crash.

The Microsoft Knowledge Base is at...


Then, at the top from the 'Support' menu, click 'Knowledge Base'.

Gary
gwinn7
 
Here is how I learned to create a search. First create a query for the table that you want to search in. In the query, put "Like [Forms]![FormName]![TextBoxName]" in the criteria for the field you will be searching under. This will filter the query and will only show records containing the contents of TextBoxName. Then you can have your subform point to the query.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top