g'day,
I put a button on a form to add records but, before doing so, I want to check if a record with the same id numbers is already in the table. To do so I use the following code:
If (DLookup("[CompanyID]", "tblBranchAddress", "CompanyID = " & Me![CompanyID] And _
"ContactsID = " & Me![ContactID])) Then
MsgBox "The name of this contact has already been recorded."
Me.Undo
' Else
' DoCmd.OpenForm "frmBranchAddress"
' DoCmd.GoToRecord , , acNewRec
' Forms!frmBranchAddress!CompanyID = Me!CompanyID
' Forms!frmBranchAddress!ContactsID = Me!ContactID
' Forms!frmBranchAddress!BranchBld.SetFocus
End If
The form consists of tabbed pages being frmCompany (the main form) and frmContacts (the sub form). I get the error "Type mismatch".
Any ideas? thanks
Dave
I put a button on a form to add records but, before doing so, I want to check if a record with the same id numbers is already in the table. To do so I use the following code:
If (DLookup("[CompanyID]", "tblBranchAddress", "CompanyID = " & Me![CompanyID] And _
"ContactsID = " & Me![ContactID])) Then
MsgBox "The name of this contact has already been recorded."
Me.Undo
' Else
' DoCmd.OpenForm "frmBranchAddress"
' DoCmd.GoToRecord , , acNewRec
' Forms!frmBranchAddress!CompanyID = Me!CompanyID
' Forms!frmBranchAddress!ContactsID = Me!ContactID
' Forms!frmBranchAddress!BranchBld.SetFocus
End If
The form consists of tabbed pages being frmCompany (the main form) and frmContacts (the sub form). I get the error "Type mismatch".
Any ideas? thanks
Dave