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!

Selecting records based on combobox listitems 1

Status
Not open for further replies.

marct

Programmer
Apr 6, 1999
32
0
0
US
Hi,<br>
<br>
I have a form that has a table as it's Record Source. I need be able to select records (whose fields will fill a bunch of textboxes on the form) based on an 'order' number, which is unique. I am loading the combo box with the order numbers, and now I need to be able to populate all the controls on the form with the record that was selected in the combobox. Problem is, I can't figure out how to do it. I've tried using the AfterUpdate event of the combobox to execute the DoCmd.FindRecord method, but it doesn't seem to do what I want. <br>
<br>
I know that this should be an easy task, as I assumed it would be, but it has proven to be more daunting than I expected. The users don't want to search using the navigation buttons, because it is too limiting. Could someone please help me out here? I would really appreciate it.<br>
<br>
Thanks in advance!<br>
<br>
-Marc
 
Marc,<br>
In the AFterUpdate of the combobox, just do<br>
<br>
Dim rst as recordset<br>
Set rst = me.recordsetclone<br>
rst.findfirst &quot;OrderNumber = &quot; & me!comboboxname<br>
If rst.nomatch then<br>
&nbsp;&nbsp;&nbsp;&nbsp;msgbox me!comboboxname & &quot; Not Found&quot;<br>
Else<br>
&nbsp;&nbsp;&nbsp;&nbsp;me.bookmark = rst.bookmark<br>
End If<br>
<br>
This assumes order number is Numeric. If string, change the findfirst criteria to:<br>
rst.findfirst &quot;OrderNumber = &quot;&quot;&quot; & me!comboboxname & &quot;&quot;&quot;&quot;<br>
<br>
--Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top