Passing Primary Key

CandyBoy

New member
Local time
Today, 08:08
Joined
Sep 28, 2001
Messages
8
Here is the code for a form that has command buttons linking to three other forms and also linking the other table to one CustID which is the primary key. The Additional Insured (AddIns) button works but the other two do not, any ideas?

Option Compare Database

Private Sub Form_Load()

End Sub
Private Sub cmd_AddIns_Click()
On Error GoTo Err_cmd_AddIns_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "AddIns"

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

Exit_cmd_AddIns_Click:
Exit Sub

Err_cmd_AddIns_Click:
MsgBox Err.Description
Resume Exit_cmd_AddIns_Click

End Sub

Private Sub cmd_Mortgage_Click()
On Error GoTo Err_cmd_Mortgage_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Mortgage"

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

Exit_cmd_Mortgage_Click:
Exit Sub

Err_cmd_Mortgage_Click:
MsgBox Err.Description
Resume Exit_cmd_Mortgage_Click

End Sub
Private Sub cmd_LossPayable_Click()
On Error GoTo Err_cmd_LossPayable_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "LossPayable"

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

Exit_cmd_LossPayable_Click:
Exit Sub

Err_cmd_LossPayable_Click:
MsgBox Err.Description
Resume Exit_cmd_LossPayable_Click

End Sub
 
I do not understand what you mean when you say, "...and also linking the other table to one CustID which is the primary key." Be that as it may, if you have a field on your form called CustID and it has a number in it then it looks like your code should work. My only suggestion would be to make another command button using the Wizard and see if that one works.
 
yeah i tried using the wizard to make another command button, and it didn't work still only the first one worked.
 

Users who are viewing this thread

Back
Top Bottom