DCount not totaling (1 Viewer)

lmcc007

Registered User.
Local time
Today, 13:01
Joined
Nov 10, 2007
Messages
635
I am trying to get the total activities per company using ActivityID as the criteria. I created the following code:

Public Function ActivityCount(ByVal strEventType As Integer) As Integer

ActivityCount = DCount("[ActivityID]", "Event", _
"[CompanyID] = " & Forms!frmViewEventHistory!txtCompanyID & " And " & _
"[ActivityID] = " & strEventType)​

End Function


Private Sub Form_Current()

Me.txtCaption = "History of Events Thru " & Me.txtEndDate & " for " & Me.txtCompanyName

Me.txtSubmitted = ActivityCount(33)
Me.txtCalls = ActivityCount(23) Or ActivityCount(24)
Me.txtSurveys = ActivityCount(11) Or ActivityCount(12) Or ActivityCount(13) Or ActivityCount(14)
Me.txtNotes = ActivityCount(22)
Me.txtPhoneSurveys = ActivityCount(40)
Me.txtSends = ActivityCount(8) Or ActivityCount(10) Or ActivityCount(20)
End Sub


The problem is when there are more than one criteria--that is:

Me.txtCalls = ActivityCount(23) Or ActivityCount(24)

it does not give me the correct total or it does not add. Then I tried it with:

Me.txtCalls = ActivityCount(23) And ActivityCount(24)

or

Me.txtCalls = ActivityCount(23 And 24)

but it does nothing.


What am I missing?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 11:01
Joined
Aug 30, 2003
Messages
36,144
Is this what you're after?

Me.txtCalls = ActivityCount(23) + ActivityCount(24)
 

lmcc007

Registered User.
Local time
Today, 13:01
Joined
Nov 10, 2007
Messages
635
Is this what you're after?

Me.txtCalls = ActivityCount(23) + ActivityCount(24)

Wow, I missed that one big time. You add--just add a plus sign.

Thank you very much!
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 11:01
Joined
Aug 30, 2003
Messages
36,144
No problemo; sometimes it's the simplest things that trip us up.
 

Users who are viewing this thread

Top Bottom