Populating data from a form to a subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am tyring to populate a field in a subform with a field from the mainform
that the subform is on. Can anyone tell me how to do this? Here is what I
think is the pertinent information:

Main form name: Account Input
Field w/ data that I want to populate the subform: client ID (is the
control source) and text355 (is the name of the field)
Subform name: timeaccount subform
field that I want to be populated with the client ID field from the account
input form:
account number (is the name)

The subform was created from a query and not a table if that makes any
difference at all.

I sincerely appreciate any help and appologize if my terms are not correct.

Thanks,
David
 
To write a value into a field or control in a subform from the main form,
use this syntax:

Me!SubformName!ControlNameOnSubform.Value = "MyValue"

where SubformName is the name of the subform control (the control that holds
the subform object).
 
Also maybe I wasn't clear. The field in my main form has a value (it is an
autoid). I would just like to put that value into a field in my subform. I'm
not really sure how to use your response. I'm a novice w/ this so I
appreciate your patience and your help.
 
No need to write the value into the subform, assuming that the autoid field
on the main form is the "linking" field for the subform's RecordSource.

Open the main form in design view, click on the subform control, open
Properties window, click on Data tab, and then:

Put the name of the autoid field in the LinkMasterFields property
box
Put the name of the field that is to get that value in subform in
the LinkChildFields property box

Be sure that the subform's RecordSource contains the field that is to get
the value.

ACCESS will do the "writing" for you -- this is how main form and sub form
are designed to work for data entry.
 
Ken,

That worked perfectly for one of my subforms, but I get the error now object
is closed or doesn't exist when I try to do the exact same thing on my other
two subforms (referencing the same field in the main form). Any suggestions?

thank you so much for your help.
 
The error suggests that the field that you're putting into one of the "Link"
properties doesn't exist either in the subform's RecordSource or in the main
form's RecordSource. Also be sure that you don't have any controls named the
same as the field to which the control is bound.

Without knowing more about what's different about the form setup that is
working and the ones that are not, this is the best I can suggest at the
moment. Feel free to post back with more details.
 
I'm not even able to put a field in the "link" properties. As soon as I
press the little button w/ the ... to allow me to choose, I get the error.
What other details can I provide?
 
You're welcome, though I admit I'm not quite sure just what it was that I
said.... < g >
 
Back
Top