DCount with multiple criteria

K

KC_Cheer_Coach

I did look this up and I just cannot apply the answers other people have
received to this mess I have created.

I need to count all the rows in the tblImportTracker table base on if the
Filename from that table matches the Filename that is chosen on the main form
and if the RunNo = RunNo and the UsagePeriod = UsagePeriod. IF all three
match, then I do not want tblImportTracker to be updated with the information
and need the txtDuplicatesWarning field on the main form to populate with
"DUPLICATE" else populate with UNIQUE and add the info to the table. I also
need to requery the subform so the information is immediately visible to the
user. (I hope that makes sense to everyone).

My DCount finally works, but now when I run it, I get this error:

Run-time error '2448': You can't assign a value to this object.

When I hit the debug button, the Me!txtDuplicatesWarning = "DUPLICATE" is
highlighted.

The txtDuplicatesWarning field is not in any of the tables. It is just an
unbound field that I placed on the main form so that the user will know if
the information is duplicate or unique. Can anyone tell me what is wrong
with this?

Private Sub USAGE_PERIOD_AfterUpdate()
If DCount("*", "tblImportTracker", "[FileName] = '" & Me![FILENAME] & "' And
[RunNo] = " & Me![RunNo] & " And [UsagePeriod] = " & Me![UsagePeriod] & "") >
0 Then
Cancel = True
Me![txtDuplicatesWarning] = "DUPLICATE"
Else
Me![txtDuplicatesWarning] = "UNIQUE"
[Forms]![frmMain].[Form]![ frmImportTracker subform].Requery
End If
End Sub

Thanks in advance!!
 
K

KC_Cheer_Coach

You can delete this posting since this question has nothing to do with the
DCount. I didn't change the subject line.
 

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