Lez said:
I have a main form with 2 sub-forms, one for clients the other for client
details.
The client records form is in continuous form view with record selector. I
want the user to be able to double click the record selector next to client
and for the clients details record to display, can anyone explain how I
could achieve this?
In the double-click event of the Record in the Form embedded in the first
Subform Control, use whatever field uniquely identifies the client, and, in
VBA code, construct and replace the RecordSource of the Form embedded in the
second Subform Control.
The only "tricky" part is referencing... from the DoubleClick event, you'd
refer to the RecordSource of the Form in the Second Subform (assuming that
second Subform Control is called "SC2") as
Me.Parent!SC2.Form.RecordSource. I don't think you will have to Requery the
second Subform Control after you reset its RecordSource, but you might.
It does not matter if the main Form is unbound or bound; nor whether or not
there's "linkage" to the first Subform in the LinkMasterFields and
LinkChildFields properties of the first Subform Control; nor if you perform
similar calculation.
However, if you (1) do not have some other kind of data on the main Form,
that determines what's in the first Subform (or even if you do, in some
cases) and (2) do not need the information from several fields to choose the
client, it might be simpler to place a ComboBox on the main Form, use the
LinkMasterFields and LinkChildFields to refer to the ComboBox and the Client
ID of the Subform. Then, in the After Update of the Combo Box, all you'll
have to do is Requery the Subform containing the Client Detail. So the user
cannot type in a value that doesn't exist for choosing client, set the
ComboBox LimitToList property to Yes.
Larry Linson
Microsoft Office Access MVP