Access VBA DCOUNT problem when two forms are involved

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?

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top