"deko" <(E-Mail Removed)> wrote in message
news:Psedne4dr-(E-Mail Removed)...
>I have an Access 2003 mdb using DAO. I have a form with a listbox, some
>textboxes, and a few subforms. The Link Child/Link Master fields are set
>linking the subforms to the main form, so subforms follow the Customer_ID
>on the main form.
>
> When a user clicks on a customer listed in the listbox, I want the
> corresponding data in the subforms to move to the record that was selected
> in the listbox. So I've been using this:
>
> Dim rst As DAO.Recordset
> Dim strCust As String
> strCust = "Customer_ID = " & Me!lstCustomer
> Set rst = Me.RecordsetClone
> rst.FindFirst strCust
> If rst.NoMatch Then
> MsgBox " Customer Not Found"
> Else
> Me.Bookmark = rst.Bookmark
> End If
>
> Is there any other way to do this? The problem is the rst is getting kind
> of big.
What do you mean by "big"? The code you posted is the standard way to do
this, and it should run very quickly if the Customer_ID field is indexed.
If the main form's recordset is big, then I would guess that the number of
rows in the list box is also getting very big, possibly bordering on
unmanageability unless you've used some tricks to filter it on the fly.
> I suppose I could assign a new RecordSource to the main form which
> contains only the selected record, but then users couldn't use
> PageUp/PageDown to scroll through the database... anyway, looking for
> alternatives...
Can we take it the main form also displays data for the customers, so you do
in fact have to position it to the selected record? If the main form is
only used to host the list box and the subforms, you don't need to bind the
main form to a table or query at all -- you can just use the list box as the
Link Master Field for your subforms, eliminating any need to navigate the
main form. But if the main form has to show data for each record, you can't
do that.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)