In Access 2000, I am working with two tables:
tblContacts
lngContactID [PK]
strNameLast
strNameFirst
strAddress
strCity
tblMemberships
lngMembershipID [PK]
dtmDateJoined
strMembershipName
strMembershipType
lngContactID [FK]
Two forms:
frmPersons [record source = tblContacts]
frmAddMembership [pop-up form, record source = tblMemberships]
I want to place a command button [cmdAddMembership] on frmPersons that when clicked, will open frmAddMembership in a new record with lngContactID filled in with the same lngContactID as was on frmPersons.
Here’s the code that I have, minus the bits that require copying lngContactID to frmAddMembership:
Private Sub cmdAddMembership_Click()
'Open frmAddMembership to a new record
DoCmd.OpenForm "frmAddMembership"
DoCmd.GoToRecord , , acNewRec
'Move cursor to the Membership Name field
Forms![frmAddMembership].[strMembershipName].SetFocus
End Sub
I am sure that this is very elementary for people who know what they are doing, but I'm only an interested user (not a techie) and struggling here. I’ve looked through the forum and could not figure out which solution would be appropriate. I would very much appreciate any help on the code required to accomplish this. Thanks in advance.
tblContacts
lngContactID [PK]
strNameLast
strNameFirst
strAddress
strCity
tblMemberships
lngMembershipID [PK]
dtmDateJoined
strMembershipName
strMembershipType
lngContactID [FK]
Two forms:
frmPersons [record source = tblContacts]
frmAddMembership [pop-up form, record source = tblMemberships]
I want to place a command button [cmdAddMembership] on frmPersons that when clicked, will open frmAddMembership in a new record with lngContactID filled in with the same lngContactID as was on frmPersons.
Here’s the code that I have, minus the bits that require copying lngContactID to frmAddMembership:
Private Sub cmdAddMembership_Click()
'Open frmAddMembership to a new record
DoCmd.OpenForm "frmAddMembership"
DoCmd.GoToRecord , , acNewRec
'Move cursor to the Membership Name field
Forms![frmAddMembership].[strMembershipName].SetFocus
End Sub
I am sure that this is very elementary for people who know what they are doing, but I'm only an interested user (not a techie) and struggling here. I’ve looked through the forum and could not figure out which solution would be appropriate. I would very much appreciate any help on the code required to accomplish this. Thanks in advance.