473,765 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 20077
Ben
On Sep 20, 9:52 am, csgraham74 <csgraha...@gma il.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
7721
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
2674
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 count automatically import and count records prompt for number of records imported import count auto-import records autoimport records count records before and after
7
1859
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; char product_type;
1
2671
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
14667
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
8191
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 calculates a percentage for all rows. This Formula Field is then used as data in a bar chart that uses FirstField for the x-axis and the percentage for the y-axis. That was all already working just fine. Now I need to change it so that the Count...
2
9016
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 patients in a table Const strDBPath = "C:\Patients.mdb" ' external database Set dbPatients = OpenDatabase(strDBPath, False, True, ";PWD=abc")
5
5417
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, polfs etc. I know how to query a date range, but not how to count number of fields within this date range. I would like the report to show date range filtered then list all changes and number of times they appear. Thanks in advance anything...
1
3612
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 via an email function. But just can't figure it out. <? //////////////////////////////////////////////////////////// //
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9399
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10163
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9957
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9835
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8832
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7379
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.