- Joined
- Dec 2, 2009
- Messages
- 1
- Reaction score
- 0
I have a main form that the user enters data into a text box, then clicks a button to open a pop-up form. The pop-up form has a few more text boxes that the user continues to enter data in. The pop-up form has a submit button that runs an append query to add the data entered from both forms. But I don't want duplicate values to append. So I came up with a DCOUNT statement that checks if two of the form fields already match two corresponding table fields. But the DCOUNT statement isn't working - the code is still allowing duplicates to be appended. Here is the code. What is wrong with it?
If the fee schedule name and state on the form fields match any rows in the table with the same fee schedule name and state, I want the code to do nothing.
Code:
Private Sub Command2_Click()
If DCount("*", "tblWeeklyChanges", "[Fee Schedule Name] = '" & Forms![Par Provider Maintenance]!AddNew & "' And [State] = '" & Me.NewState & "'") = 0 Then
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryInsertNewFS"
DoCmd.SetWarnings True
Else
End If
End If
Forms![Par Provider Maintenance].Refresh
End Sub
If the fee schedule name and state on the form fields match any rows in the table with the same fee schedule name and state, I want the code to do nothing.