Subform Question

  • Thread starter Thread starter Graham Naylor
  • Start date Start date
G

Graham Naylor

Hi,

I've got the usual form with a suform, except that I would like some fields
on the subform to be displayed on the main form as well, this is easily done
in code but becomes a nightmare if the user updates these values on the main
form.

Rather than setting them as read-only is there a way of linking them
directly (with the Control Source property?).

Any ideas?

Thanks

Graham
 
Hi,

I've got the usual form with a suform, except that I would like some fields
on the subform to be displayed on the main form as well, this is easily done
in code but becomes a nightmare if the user updates these values on the main
form.

Rather than setting them as read-only is there a way of linking them
directly (with the Control Source property?).

Typically a Subform will have many records for each mainform record.
Which record do you want displayed!?

If you want to see the value of the "active" - user selected - record
on the subform, you can set the Control Source of a mainform textbox
to

=subMySubform.Form!controlname

where subMySubform is the name of the Subform control (which might or
might not be the same as the name of the Form within that control).
You may need to requery the mainform textbox in the Subform's Current
event:

Parent!txtShowSubformData.Requery
 
Hi,

That works fine, thanks and all the required fields display properly but
will not allow updates to be made on the main form (they can be updated on
the subform), is it possible to make them display/edit fields and if so how?

Thanks

Graham
 
Yes - just put then following into the controlsource of the textbox on the
main form:

=[MySubFormControlName].[Form].[MyControl]

Replace 'MySubFormControlName' with the name of the subform control on the
main form. Note that this is not necessarily the same as the name of the
form object that is referenced in the ControlSource of the subform control.
To be sure, open the main form and click once on the subform then check the
name property under the Other tab. Whatever you find there is what belongs
in place of MySubFormControlName.

Also replace 'MyControl' with the name of the control on the subform.
 
That works fine, thanks and all the required fields display properly but
will not allow updates to be made on the main form (they can be updated on
the subform), is it possible to make them display/edit fields and if so how?

What's the Control Source of the textbox you're trying to update? What
are the Recordsources of the form and the subform? It sounds like
you're trying to simultaneously update the same table/same field on a
form and a subform, which would be a bit odd. Could you explain the
context?
 
Sorry, I meant to post a note letting you know that I have fixed the
problem, thanks for the help anyway.

Graham
 
Back
Top