Transfer contactID to Event Registration

D

Doctor

On a Contacts form, I want to be able to register a contact for an event, and
when I click on the button I want the contact's information to appear on the
registration form. I have this code that I thought worked, but only opens up
a blank registration form.

Any help would be greatly appreciated.

Private Sub LLCReg_Click()
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "LLCRegistrations"

stLinkCriteria = "[ContactID]=" & Me![ContactID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

Thanks in advance.
 
J

Jeff Boyce

What is the relationship between Contacts and Registrations (for events)?
If a Contact can register for more than one event (over time), you'll need a
way for Access to keep track of this one-to-many relationship.

It all starts with the data ... and you've only described the form.

I have a hunch you need:

tblContact
ContactID
ContactFirstName
...

tblEvent
EventID
EventTitle
EventDate
...

trelRegistration
RegistrationID
ContactID
EventID
RegistrationDate
...

And you'd use a main form (contact)/sub-form (registration) construction.
This way, your main form would bring up Contact info, and your subform would
allow you to "sign up" a contact for an event.

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
K

Klatuu

The way you are opening the form will not transfer the value of the ContactID
to the form. It only tries to filter the form's recordset based on that
value. You get a blank record because the contact does not exist as a
registrant. I would suggest you open the form in Add mode and pass the
ContactID using the OpenArgs argument of the Openform. Then in the form you
are opening, use the form's Load event to populate the control on the form
where you want the ContactID to be.
 

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