473,385 Members | 1,372 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

count number of instance of a string in a field

Hi Guys,

I was wondering if soemone could help me.

Im trying to write a piece of code that queries a field in ms access
for a keyword. what i want to do is count the number of times the
keyword exists in the memo field and store that in a temporary table.

My problem is the query to count the number of times the keyword is in
the field.

can anyone please help me ??

thanks

CG

Sep 20 '07 #1
3 19998
Ben
On Sep 20, 9:52 am, csgraham74 <csgraha...@gmail.comwrote:
Hi Guys,

I was wondering if soemone could help me.

Im trying to write a piece of code that queries a field in ms access
for a keyword. what i want to do is count the number of times the
keyword exists in the memo field and store that in a temporary table.

My problem is the query to count the number of times the keyword is in
the field.

can anyone please help me ??

thanks

CG
You could use nested instr functions. Just start the next instr after
the substr where it found the last one. You just won't be able to
search for more then 5 or 6 words because the query will be too
complex to run.
e.g.
str = "String to be searched for a string"
iif(instr(0, str, "string")>0, iif(instr(0, instr(0, str, "string") -
(len(str)+len("string"), "string")>0, 2,1),0)

Otherwise you will need to make a VBA function to loop through the
words in the string to find what your looking for.

Sep 20 '07 #2
On Thu, 20 Sep 2007 09:52:59 -0700, csgraham74 wrote:
Hi Guys,

I was wondering if soemone could help me.

Im trying to write a piece of code that queries a field in ms access
for a keyword. what i want to do is count the number of times the
keyword exists in the memo field and store that in a temporary table.

My problem is the query to count the number of times the keyword is in
the field.

can anyone please help me ??

thanks

CG
NumberOfTimes:(Len([FieldName])-Len(Replace([FieldName],"bus","")))/3

Let's say you wish to count the number of times the word "bus" appears
in a field.
THE BUS IS A VERY BUSY BUSINESS. The query would return back a "3".

The /3 part is whatever the number of characters in the search string
(i.e. "bus") is.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Sep 20 '07 #3
that is fantastic exactly what im after - i now have to apply this to
some sort of keyword search. ie. to find the records that contain the
greatest number of instances of a certain set of keywords.

i should be able to adapt this - thank-you
Sep 21 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: vic | last post by:
Hello, Dean Try this: select distinct c1, c2 into #tmp_1 from t1 select count(*) as cnt from #tmp_1 drop table #tmp_1 With best regards.
0
by: DataFreakFromUtah | last post by:
Hello! No question here, just a procedure for the archive. Search critera: count records imported count data imported count number of rows imported count number of records imported record import...
7
by: happy | last post by:
I will reissue my question . How to form and write string field to a disk file in one statement usinf fprintf? my struct as below : struct record { char customer_name; int customer_no;...
1
by: tranky | last post by:
hi, only one information,please... how to count number of anonymous online users? I use ASP.NET 2.0 thank u tranky
11
by: Mack | last post by:
Hi all, I want to write a program to count number of bits set in a number. The condition is we should not loop through each bit to find whether its set or not. Thanks in advance, -Mukesh
0
denny1824
by: denny1824 | last post by:
I have a crystal report that someone else wrote and already has a Formula Field if Criteria then (Count ({FirstField},{SecondField}) / Count ({FirstField})) When the Criteria is true, this...
2
by: mfaisalwarraich | last post by:
Hi Everybody, I am using the following code to get the recordset of an external database. Dim dbPatients As Database Dim rsCountPatients As Recordset ' to count number of...
5
by: jambonjamasb | last post by:
I am wanting to create a report that summarises the number of items within a date range. For example I have a FIELD called System_Change. This is a drop down COMBOBOX that uses words like unix,...
1
by: jlt206 | last post by:
This code <?php include("counter.php")?> on the webpage produces the count number. (function code below) I want to place the current number into a variable $MemberNo or into a FormField to be sent...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.