2 Table Design Question

I

iam

I have in Access 2000 a Contact Database with roughly 20 fields in a
primary table called Contacts.

On the same form, I have placed a Command Button to open a second
table called Donations in Edit Mode to be able to record A Donation.

The untimate goal being to be able to record multiple donations for
each contact.

The Donations Table has 4 Fields.

In Contacts Table I have a ContacID Text Field set up as Primary Key.
I have it set for a 1 to Many relationship to Donations using a
ContactID Text field there also.

Problem I have is, when I open Donations using the button, I want the
ContactID field in Donations to automatically fill in with whatever
ContactID value is in the record that opens it. Right now it is blank.

I have Referential Integrity set for both updates and deletes.

How do I get the value to transfer?
By adding what, to the On Click procedure attached to the button.

Right now this is the code I have there.

Private Sub Donations_Click()
On Error GoTo Err_Donations_Click
If IsNull(Me![ContactID]) Then
MsgBox "Enter doner information before entering order."
Else
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
DoCmd.OpenForm "Donations", , , , acEdit
End If

Exit_Donations_Click:
Exit Sub

Err_Donations_Click:
MsgBox Err.Description
Resume Exit_Donations_Click
End Sub
 
A

Allen Browne

To pass the ContactID from the current form to a new donation in the other
form:

If IsNull(Me![ContactID]) Then
MsgBox "Enter doner information before entering order."
Else
If Me.Dirty Then Me.Dirty = False
DoCmd.OpenForm "Donations", DataMode:= acFormAdd
Forms("Donations")!ContactID = Me.ContactID
End If

Note that this won't work correctly if the other form is already open.
 

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