I'm adding data to several tables with a single form using INSERT SQL and the Dmax method to sort relations.
On one of the tables there is the potential for duplicates which I want to avoid.
Please can someone provide an example of DMax or DCount or other method that I can use to decide whether to run the INSERT SQL Code.
So far I have;
If IsNull(DMax("PrimaryID", "
", "Criteria = " _
& Field1 = [Control1] & " AND " & "Field2 =" & "[Control2]")) = True Then
'Nothing
Else
DoCmd.RunSQL
This produces an incorrect result, always reports a Null. I'm using MsgBoxes at the moment to relay the result.
Any help, much appreciated. I have searched high and low for examples pulling values from controls but I only get examples using variables in the code.
On one of the tables there is the potential for duplicates which I want to avoid.
Please can someone provide an example of DMax or DCount or other method that I can use to decide whether to run the INSERT SQL Code.
So far I have;
If IsNull(DMax("PrimaryID", "
& Field1 = [Control1] & " AND " & "Field2 =" & "[Control2]")) = True Then
'Nothing
Else
DoCmd.RunSQL
This produces an incorrect result, always reports a Null. I'm using MsgBoxes at the moment to relay the result.
Any help, much appreciated. I have searched high and low for examples pulling values from controls but I only get examples using variables in the code.