VBA Child Value

G

Guest

I have a main form which is a datasheet. It has a subform which is a
continuous form. Click on the + sign on the datasheet and open the
continuous form.

In order to manage data entry on the subform, I want to create some default
values that relate to the values in the parent child relationship. The forms
are linked by two values. AccountNo and ItemNo.

The problem is that the default values in the subform are for the first
record in the datasheet regardless of how many rows down the datasheet I am.
For example if the first record is account 1000 and Item 1, this is the
default value for every subform.

My first solution was to use VBA to somehow capture the values in the parent
child link for each row in the datasheet and make them the default. Sort of
subform.txtBox1.default = childfield.value(1) and subform.txtBox2.default =
childfield.value(2)

I have not been able to find how to refer to the value in the link much less
how to separate two values. Can anyone help in identifying the way to
capture the value or point me in another direction.

Thanks
 
G

Guest

You might try
subform.txtbox1.default=Form_main.AccountNo.value
and
subform.txbox2.default=Form_main.ItemNo.value.

Add the statements in the subform's "current" event routine.
 
G

Guest

Thanks Joe. I tried that. The problem is it always puts in the value from
the first record in the dataset. If I select record 3 in the dataset, it
still puts in the default account code from record 1.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top