Master Detail

T

TB

I have a Form with a Master record displayed (it's called
frmMembersAndDonations). The calling form opens frmMembersAndDonations with
this:
DoCmd.OpenForm "frmMembersAndDonations", acNormal, , "[Member ID]=" &
Me.Member_ID

I have a subform with a Detail record displayed as a Datasheet (it's called
frmsubDonations)

Everything works great (master record displayed correctly, all existing
detailed records displayed correctly) EXCEPT:

When I click on the NEW record row, I have to MANUALLY enter the MemberID
value that is the link to the Master record.

What I want is for the form to automatically use the value from the Master
form or record on the Detail form and record. How can I do this?

Many thanks...
 
K

KARL DEWEY

Sounds like you need to create a one-to-many relationship between table for
Master Record and Donations. Set referential integrity and cascade updates.
Then open your form in design view and set Master/Child links using the
[Member ID] for form/subform.
When you add a row to subform it will automatically add the [Member ID].
 
M

Marshall Barton

TB said:
I have a Form with a Master record displayed (it's called
frmMembersAndDonations). The calling form opens frmMembersAndDonations with
this:
DoCmd.OpenForm "frmMembersAndDonations", acNormal, , "[Member ID]=" &
Me.Member_ID

I have a subform with a Detail record displayed as a Datasheet (it's called
frmsubDonations)

Everything works great (master record displayed correctly, all existing
detailed records displayed correctly) EXCEPT:

When I click on the NEW record row, I have to MANUALLY enter the MemberID
value that is the link to the Master record.

What I want is for the form to automatically use the value from the Master
form or record on the Detail form and record. How can I do this?

If you could make the detail form a subform of the master
form, the LinkMaster/Child properties would make all of that
automatic.

As it is, I suggest that you pass the member ID value in the
OpenForm method's OpenArgs argument. Then, in the detail
form's BeforeUpdate (or maybe BeforeInsert) event, set the
field's value using code like:

Me.MemberID = Me.OpenArgs
 

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