Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access - Count the number of times a word appears

Status
Not open for further replies.

bf2mad

Programmer
Nov 26, 2002
33
GB
Hi,

I have a problem with MS Access 2000. I have a combo box on a form with four options Resolved, Reassigned, Rejected, Call Over 20Mins. After the user has made they selection I need to be able to count however resolved, reassigned etc there currently are.

The form runs though a query so the form just display information for that user.

So all I need is to be able to count the number of times these words appear on my form and then display these totals on the form in a label\ textbox etc

Form name: EmailDatasheetForm
Query Name: E-mail Datasheet Query
Combo Box Name: Combo18
Label Names: label46, label48, label50, label52

Many Thanks

Phil
 
I got this one for you!!

put this in your onform load:

dim counter(4) as integer
dim i as integer
dim db as database
dim myrecord as recordset

set db = currentdb()
set myrecord =db.openrecordset("TABLE WHERE COMBO COMES FROM")
If myrecord.BOF = True Then Exit Sub
With myrecord
If .RecordCount Then
.MoveFirst
Do Until myrecordset.EOF
if ![YOUR FIELD WHERE COMBO LOADS FROM] = VALUE BEING COUNTED
count(1) = count(1) +1
else if ![YOUR FIELD WHERE COMBO LOADS FROM] = 2nd VALUE BEING COUNTED
count(2) = count(2) +1
else if ![YOUR FIELD WHERE COMBO LOADS FROM] = 3RD VALUE BEING COUNTED
count(3) = count(3) +1
else if ![YOUR FIELD WHERE COMBO LOADS FROM] = 4TH VALUE BEING COUNTED
count(4) = count(4) +1
end if
Loop
End If
End With
label46.caption = count(1)
label48.caption = count(2)
label50.caption = count(3)
label52.caption = count(4)


I pulled this out of my rump, but i think it'll work :) should atleast!! Cruz'n and Booz'n always.
This post shows what little I do at work.
 
OH, extra note, everything that is in ALL CAPS you have to fill in for whatever it specifies.

also if you want you can use a switch instead of the if statement. I typed this in a hurry ;-) Cruz'n and Booz'n always.
This post shows what little I do at work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top