Count the Two combination fields repeated (1 Viewer)

gramesh

New member
Local time
Today, 23:10
Joined
Feb 27, 2016
Messages
3
Hi,
i want to auto count the contact in two field combination repeated,
i tried the VBA afterupdate but not matching exactly.
I used this code, but not couting exactly

Private Sub surname_afterUpdate()
[contact] = 1
contact = (DCount("[FirstName]", _
"Employee", "[FirstName] ='" _
& Me!Firstname & "'")) And (DCount("[Surname]", _
"Employee", "[Surname] ='" _
& Me!Surname & "'"))

End Sub

I want the contact count exactly as
Firstname Surname contact
ramesh gr 1
mouli gr 1
ramesh gr 2
harini ab 1
ramesh gr 3
abcde ab 1
ramesh ab 1
mouli gr 2
harini ab 2
Please help any one to make correct code or other method of counting.
Thanks in advance
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:40
Joined
May 7, 2009
Messages
19,242
[contact] = Nz(DCount("[FirstName] & [SurName]", "Employee", "[FirstName] & [SurName] = '" & Me.FirstName & Me.SurName & "'"), "")

you should not save this in a field, since it can be computed on the fly.
 

gramesh

New member
Local time
Today, 23:10
Joined
Feb 27, 2016
Messages
3
Hello Arnelgp,
Thanks for your reply and i checked your code, it's work fine.
You are great man
Thank you for fast reply , Thanks Arnelgp
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:40
Joined
May 7, 2009
Messages
19,242
you're welcome.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 10:40
Joined
Aug 30, 2003
Messages
36,125
FYI, moved thread out of introductions.

That produces a total count, not the running count in your example.
 

Users who are viewing this thread

Top Bottom