Updating a field on a subfrom from a field on its master form

G

Guest

Hi all:
What I am tyring to do is have access automaticaly update a field on my
subform with data from my master form whenever the user makes changes to the
field on the master form. There is a one to many relationship between the
record on the main form and the record on the subform. Normally the user
never has to enter any data for this field as I populate it via the default
value (=[Forms]![frmIntakeDataEntry]![GrowerID]). My problem is when the
user makes changes to the field on the master form I can not get the form to
automaticaly update the field on the subform.

What I have been tryiing so far is to run an update querry on the table
(tblBins) that is the record source for the subform. I have been running the
querry from the "AfterUpdate" for the field on the master form. The querry
seems to be working correctly but the subfrom will just not show the new
data. I have tried to requery, refresh and repaint the forms but it just
will not work. What am I doing wrong?

Details:
master form name: frmIntakeDataEntry
subform name: frmIntakeSubFormBins
field on master form: GrowerID
field on subform: BinGrowerID
recordsource for master form: tblIntake (parent/one table)
recordsource for subform: tblBins (child/main table)
relationship: one to many

If anyone could offer some help I would appreciate it greatly.

Thanks,
FatMan
 
G

Guest

Hi all:
Just realized that I did not state in my first post that while there is a
one to many relationship between the two tables (master form/subform) the
field in question is NOT the primary/foreign key.

Hope someone out there can help.

Thanks,
FatMan
 
S

SusanV

Hi FatMan,

It would be simpler and easier to update it via VBA in the Main form's
control's On Update event:

Me!frmIntakeSubFormBins.Form!BinGrowerID = Me.GrowerID


--
hth,
SusanV


FatMan said:
Hi all:
Just realized that I did not state in my first post that while there is a
one to many relationship between the two tables (master form/subform) the
field in question is NOT the primary/foreign key.

Hope someone out there can help.

Thanks,
FatMan

FatMan said:
Hi all:
What I am tyring to do is have access automaticaly update a field on my
subform with data from my master form whenever the user makes changes to
the
field on the master form. There is a one to many relationship between
the
record on the main form and the record on the subform. Normally the user
never has to enter any data for this field as I populate it via the
default
value (=[Forms]![frmIntakeDataEntry]![GrowerID]). My problem is when the
user makes changes to the field on the master form I can not get the form
to
automaticaly update the field on the subform.

What I have been tryiing so far is to run an update querry on the table
(tblBins) that is the record source for the subform. I have been running
the
querry from the "AfterUpdate" for the field on the master form. The
querry
seems to be working correctly but the subfrom will just not show the new
data. I have tried to requery, refresh and repaint the forms but it just
will not work. What am I doing wrong?

Details:
master form name: frmIntakeDataEntry
subform name: frmIntakeSubFormBins
field on master form: GrowerID
field on subform: BinGrowerID
recordsource for master form: tblIntake (parent/one table)
recordsource for subform: tblBins (child/main table)
relationship: one to many

If anyone could offer some help I would appreciate it greatly.

Thanks,
FatMan
 
G

Guest

SusanV:
Thanks for your reply.

I do not think this will work as there is a one to many relationship between
the record on the master form and the subform. I believe your suggestion
will only update one of the occurances of the record in the subform.

Once again thanks for taking the time to reply to my question, your
suggestion is greatly appreciated.

Thanks,
FatMan
SusanV said:
Hi FatMan,

It would be simpler and easier to update it via VBA in the Main form's
control's On Update event:

Me!frmIntakeSubFormBins.Form!BinGrowerID = Me.GrowerID


--
hth,
SusanV


FatMan said:
Hi all:
Just realized that I did not state in my first post that while there is a
one to many relationship between the two tables (master form/subform) the
field in question is NOT the primary/foreign key.

Hope someone out there can help.

Thanks,
FatMan

FatMan said:
Hi all:
What I am tyring to do is have access automaticaly update a field on my
subform with data from my master form whenever the user makes changes to
the
field on the master form. There is a one to many relationship between
the
record on the main form and the record on the subform. Normally the user
never has to enter any data for this field as I populate it via the
default
value (=[Forms]![frmIntakeDataEntry]![GrowerID]). My problem is when the
user makes changes to the field on the master form I can not get the form
to
automaticaly update the field on the subform.

What I have been tryiing so far is to run an update querry on the table
(tblBins) that is the record source for the subform. I have been running
the
querry from the "AfterUpdate" for the field on the master form. The
querry
seems to be working correctly but the subfrom will just not show the new
data. I have tried to requery, refresh and repaint the forms but it just
will not work. What am I doing wrong?

Details:
master form name: frmIntakeDataEntry
subform name: frmIntakeSubFormBins
field on master form: GrowerID
field on subform: BinGrowerID
recordsource for master form: tblIntake (parent/one table)
recordsource for subform: tblBins (child/main table)
relationship: one to many

If anyone could offer some help I would appreciate it greatly.

Thanks,
FatMan
 
J

John Vinson

Hi all:
What I am tyring to do is have access automaticaly update a field on my
subform with data from my master form whenever the user makes changes to the
field on the master form. There is a one to many relationship between the
record on the main form and the record on the subform. Normally the user
never has to enter any data for this field as I populate it via the default
value (=[Forms]![frmIntakeDataEntry]![GrowerID]). My problem is when the
user makes changes to the field on the master form I can not get the form to
automaticaly update the field on the subform.

What I have been tryiing so far is to run an update querry on the table
(tblBins) that is the record source for the subform. I have been running the
querry from the "AfterUpdate" for the field on the master form. The querry
seems to be working correctly but the subfrom will just not show the new
data. I have tried to requery, refresh and repaint the forms but it just
will not work. What am I doing wrong?

Your update query is the proper approach. How are you doing the
requery? Me!subformname.Form.Requery would probably be the proper
command (in an [Event Procedure] of course).

John W. Vinson[MVP]
 

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