Master Detail

  • Thread starter Thread starter TB
  • Start date Start date
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...
 
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].
 
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
 
Back
Top