Code to test if a record has been created using a field from the parent form and one from the sub form

Giganews Newsgroups
Subject: Code to test if a record has been created using a field from the parent form and one from the sub form
Posted by:  pritchard.tre…@gmail.com
Date: Sun, 31 May 2020

I need to stop users from duplicating records that record info. from a main form (frmCRMEditRf) and a sub form (frmCRMPartsRF)
The field in the main form is txtActionNumber  (text) and the field in the sub form is cboPartNumber (a number field).
My code..including many fails:

CHKID = Me!txtActionNumber
CHKProdID = Me!frmCRMPartsRF!cboPartNumber

        'Tot = DCount("[RepReportID]", "tblRepReport", "[ProductID] = CHKProdID And [RPIdentifier] = " & Chr(34) & "CHKID" & Chr(34))
        'Tot = DCount("[RepReportID]", "tblRepReport", "[ProductID] = " & Forms![frmCRMPartsRF.Form!cxboPartNumber]
        'Tot = DCount("[RepReportID]", "tblRepReport", "[ProductID] = " & CHKProdID & " AND _[RPIdentifier] = " & CHKID)
        'Tot = DCount("[RepReportID]", "tblRepReport", "[ProductID] = CHKProdID" And "[RPIdentifier] = '" & CHKID & "'")
          Tot = DCount("[RepReportID]", "tblRepReport", "[RPIdentifier] = '" &  & "' And "[ProductID] = " & CHKProdID)
I would then use this code in an IF statement

Thanks for any help
Bob

Replies