Client Form How To Transfer ClientID to Appointments

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • topthebookie
    New Member
    • Feb 2008
    • 11

    Client Form How To Transfer ClientID to Appointments

    Good Day,

    I am a newbie to access. Currently running 2003 version. I have created a clients table with a command button "Schedule Estimate" which goes to my client appointments form. I am wondering if there is a way to transfer the ClientID over to the schedule estimate form when I click "Schedule Estimate". On the Client Appointments form I have ClientID, EstimateID, EstimateDate, EstimateTime. Any help is appreciated.

    Thank You,

    Steve
  • mshmyob
    Recognized Expert Contributor
    • Jan 2008
    • 903

    #2
    If you have your relations setup properly then ClientID is a foreign key in your appointment table.

    Create a Main form / subform and your key will be updated properly.

    That is only 1 way - there are many others. You can pass it via code if you have 2 forms open

    Say frmClient and frmAppointment

    [CODE=vb]
    'pass from frmClient to frmAppointment
    ' both forms must be open
    Forms!frmAppoin tment.ClientID = Me.txtClientID. Value
    [/CODE]

    Originally posted by topthebookie
    Good Day,

    I am a newbie to access. Currently running 2003 version. I have created a clients table with a command button "Schedule Estimate" which goes to my client appointments form. I am wondering if there is a way to transfer the ClientID over to the schedule estimate form when I click "Schedule Estimate". On the Client Appointments form I have ClientID, EstimateID, EstimateDate, EstimateTime. Any help is appreciated.

    Thank You,

    Steve

    Comment

    • topthebookie
      New Member
      • Feb 2008
      • 11

      #3
      [code=vb]
      Private Sub ScheduleEstimat e_Click()
      On Error GoTo Err_ScheduleEst imate_Click

      Dim stDocName As String
      Dim stLinkCriteria As String

      stDocName = "Client Estimate Appointments"

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

      Exit_ScheduleEs timate_Click:
      Exit Sub

      Err_ScheduleEst imate_Click:
      MsgBox Err.Description
      Resume Exit_ScheduleEs timate_Click

      End Sub[/CODE]
      here is my code, if you can help with this that will help me out. I am learning therefore want to see how it would be done. Thank You.

      Comment

      • mshmyob
        Recognized Expert Contributor
        • Jan 2008
        • 903

        #4
        Assuming you have no Errors just add the following after your OpenForm command.

        Of course change the control names to match yours....

        [CODE=vb]
        Forms!frmForm2. txtClientIDRece ive.value = Me.txtClientIDF rom.Value
        [/CODE]

        Comment

        Working...