Displaying a record in a subform.

B

bvdahl

Hello,

This is probably really easy, but I am stuck big time anyway.

I have a main form (search) and a sub form (details). In the main form,
there is a list box displaying a filtered selections of clients. In the sub
form, the user can edit the address and contact details of clients.

What I would like to do, is when the user clicks a client in the main form's
list box, that clients record is displayed in the sub form, ready to be
edited.

I have struggled for many hours now, and I would really appreaciate som help.

thx

Baard
 
R

Rick Brandt

bvdahl said:
Hello,

This is probably really easy, but I am stuck big time anyway.

I have a main form (search) and a sub form (details). In the main
form, there is a list box displaying a filtered selections of
clients. In the sub form, the user can edit the address and contact
details of clients.

What I would like to do, is when the user clicks a client in the main
form's list box, that clients record is displayed in the sub form,
ready to be edited.

I have struggled for many hours now, and I would really appreaciate
som help.

thx

Baard

Set the Masterlink property of the subform control to the name of the ListBox
and the Childlink property to the matching field in the subform.
 
B

bvdahl

Hello,

Thank you for your very quick reply

I probably should have pointed out that the main form is unboundIt is really
just a textbox that starts a SQL statement that populates the listbox.

The subform is linked to the client database.

When I try to do something with the 'Link Child Fields' and 'Link Master
Fields', I get an error message saying 'Can't build a link between unbound
forms'.

I've tried my way with the little VBA that I know, but so far with little
success.

Baard
 
R

Rick Brandt

bvdahl said:
Hello,

Thank you for your very quick reply

I probably should have pointed out that the main form is unboundIt is
really just a textbox that starts a SQL statement that populates the
listbox.

The subform is linked to the client database.

When I try to do something with the 'Link Child Fields' and 'Link
Master Fields', I get an error message saying 'Can't build a link
between unbound forms'.

I've tried my way with the little VBA that I know, but so far with
little success.

It is true that you can't use the builder form for setting the MasterLink and
ChildLink properties when either form is unbound. However; there is nothing to
prevent you from manually making the appropriate entries. Just click in the
property box and type the entries from the keyboard.
 
R

Rick Brandt

bvdahl said:
Hello,

Thank you for your very quick reply

I probably should have pointed out that the main form is unboundIt is
really just a textbox that starts a SQL statement that populates the
listbox.

The subform is linked to the client database.

When I try to do something with the 'Link Child Fields' and 'Link
Master Fields', I get an error message saying 'Can't build a link
between unbound forms'.

I've tried my way with the little VBA that I know, but so far with
little success.

It is true that you can't use the builder form for setting the MasterLink and
ChildLink properties when either form is unbound. However; there is nothing to
prevent you from manually making the appropriate entries. Just click in the
property box and type the entries from the keyboard.
 
B

bvdahl

ok, I see.

Could I bother you to tell me the syntax?

I tried Forms![mainform]![listboxname] in master and customer_id in the
child, but that didn't work.

Baard
 
R

Rick Brandt

bvdahl said:
ok, I see.

Could I bother you to tell me the syntax?

I tried Forms![mainform]![listboxname] in master and customer_id in
the child, but that didn't work.

In MasterLink you would just put the name of the ListBox

listboxname

In ChildLink you would put the name of the *field* in the subform that should
match the value chosen in the ListBox. That's an important distinction. The
MasterLink can be a field name or a control name or in fact any legal
expression. The ChildLink must be a field name or an expression that references
a field name.
 
B

bvdahl

Great, that worked.

Thanks a lot

Baard

Rick Brandt said:
bvdahl said:
ok, I see.

Could I bother you to tell me the syntax?

I tried Forms![mainform]![listboxname] in master and customer_id in
the child, but that didn't work.

In MasterLink you would just put the name of the ListBox

listboxname

In ChildLink you would put the name of the *field* in the subform that should
match the value chosen in the ListBox. That's an important distinction. The
MasterLink can be a field name or a control name or in fact any legal
expression. The ChildLink must be a field name or an expression that references
a field name.
 
Top