Use of inStr in a DCount

Newman

Québécois
Local time
Today, 09:41
Joined
Aug 26, 2002
Messages
766
I have a field in my report that should tell me how many times you can see a particular string in a table.

Note that it could be:
At the begining: MYSTRINGabcdef
In the middle: abcMYSTRINGdef
At the end: abcdefMYSTRING

I tried this:
DCount("[MyField]", "MyTable", "InStr([MyString],[MyField])>0")
But it doesn't work.
I tried many others, but it never worked either. That one, I believe to be the closest to the real thing).

Thank you for your help!
 
Well you could try this. Put this expression in the Control Source for a textbox in the Group Footer or the Report Footer.
=Sum(IIf(InStr(1,[MyField],"MyString")>0,1,0))

See if that works. It should, I just tested it.

Paul
 
Last edited:
Hi

I tried this in a query and it worked fine ..

SELECT DCount("[Customer Name]","TABLE","InStr([Customer Name],'Pre')>0") AS Expr1;

Could it be coz you are doing "InStr([MyString],[MyField])"
instead of "InStr([MyField],[MyString])" ?

Gina.
 
Thank you Paul for the answer. It solves my problem perfectly.
NOL > It was an error I made in typing it in the thread. It was written the right way in the database. Thank you anyway!
 

Users who are viewing this thread

Back
Top Bottom