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!

count records that contain a string within a string

Status
Not open for further replies.

cynaptic

Programmer
Sep 13, 2001
54
GB
I have a column, that contains up to three words/phrases seperated by a comma.

I would like to count the number of times a record containing a certain word occurs.

I think i should be using the inSTr function but am not sure quite how - as i have never used it before and only found out existed by scouring these sacred forums

not looking for someone to do my work for me - just some pointers

thanks
 
Hi!

Try using the DCount function:

DCount("YourField", "YourTable", "Where YourField Like *WordYouAreLookingFor*")

hth Jeff Bridgham
bridgham@purdue.edu
 
Jeff

thanks for you rinput - looks a far beter bet than the way I was going....

have produced

SELECT DCount("[operating_systems]", "softacad", "where [operating_systems] like "Windows 98"");

but am told by Access tha I am missing an operator

alex
 
Hi Alex!

Try using single quotes around Windows 98 and let me know what you get.

hth Jeff Bridgham
bridgham@purdue.edu
 
Hi Jeff

SELECT DCount("[operating_systems]", "softacad", "where [operating_systems] like 'Windows 98'");

slightly different this time - changed to single quotes and now am getting 'includes reserved word or an argument name that is mispelled or the punctuation is incorrect'

have tried putting 'windows 98' in brackets but that didn't help either.

Alex
 
Hi Alex!

I don't know if this is the problem or not, but you need an asterick on each side of Windows 98.

hth Jeff Bridgham
bridgham@purdue.edu
 
try this

Dim lngCount as Long
lngCount = DCount("[operating_systems]", "softacad", "[operating_systems] like 'Windows 98'")
MsgBox "Number of Systems: " & lngCount

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top