DAO RecordSet - selecting a specific record

scottydel

Registered User.
Local time
Today, 11:17
Joined
Apr 18, 2007
Messages
35
Hello,

I have a question on DAO.

I have a Single form that is bound to a table with 15,000 records. The form has several controls that are each bound to a field in the table. I have a combo box that is bound to a query that selects the primary key of each of the 15,000 records. If I select one specific value from this combo box, I would like the current record in the recordset to jump to that specific record, thus populating all of the form's controls with that record's values.

Is there a quick way to do this in DAO?

I have thought of putting in a loop, and using Recordset.MoveNext and checking the Field in the current record against the field chosen in the combo box, but this seems tedious (esp. for 15,000 records). Any way to jump directly to a specific record in a DAO recordset, keyed off of a field value (or something else?) and not have to use Recordset.MoveNext in a loop?

Thanks,

Scott
 
Try the combo box wizard. The third option will build the code for you. It will NOT involve a loop.
 
pbaldy thank you, that is just what I was looking for :)

-Scott
 
Also, keep in mind that generally speaking, queries does things faster than similar DAO processes. You can just build a query and use it as combobox's rowsource.

Furthermore, it will run faster if you use criteria to narrow the set or even put on a cap on number of records returned.

DAO is great when doing something that would be convulted or require complex logic that query builder can't handle.
 
Banana,

Thanks for the info. I am using a query in the Row Source of the Combo Box. I wanted to use DAO to add a little search feature to the app, which tied the Combo Box's selected value to the current record on the form, and hence the rest of the Form's Controls.

The tip above worked using the wizard which ultimately uses the DAO.recordset FindFirst method and Bookmark property.

I don't hav the luxury of restricting my search! It's gotta be all 15,000 records, every time.

-Scott
 
Oh yeah, the Bound Column property of the ComboBox was also something that's used to link the Combo Box to the Form...
 

Users who are viewing this thread

Back
Top Bottom