|
From: Doctor on 1 Jul 2008 15:14 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.
From: Jeff Boyce on 1 Jul 2008 15:40 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 "Doctor" <Doctor(a)discussions.microsoft.com> wrote in message news:622B0184-B09B-4C45-BEFE-1DA5F38FA3D2(a)microsoft.com... > 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.
From: Klatuu on 1 Jul 2008 15:46 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. -- Dave Hargis, Microsoft Access MVP "Doctor" wrote: > 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.
|
Pages: 1 Prev: Access set fields equal using visual basic Next: Forms based on a query |