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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

InStr Formula

Status
Not open for further replies.

mmt4331

Programmer
Dec 18, 2000
125
US

I'm trying to find the string "ggiv" w/in a database field and then accumulate the counter variable by one. It is giving me nothing but 0. I put it in the detail and the RF section of the Report but I still get 0's. Here is the formula below:


WhileReadingRecords;

numberVar ggivCounter;

if InStr(1,{TurnOver_Logs_v2._3},"ggiv") = 1 then
(
ggivCounter := ggivCounter + 1;
);


 
You want to go with
Code:
WhileReadingRecords;

numberVar ggivCounter;

if InStr(1,{TurnOver_Logs_v2._3},"ggiv") > 0 then
(
    ggivCounter := ggivCounter + 1;
);
Naith
 
The formula you posted will only increase the counter if the string you are searching has the "ggiv" at the begining of the string.

if InStr(1,{TurnOver_Logs_v2._3},"ggiv") = 1 then

I would use the following instead:


While ReadingRecords;

numberVar ggivCounter;

if "ggiv" in {TurnOver_Logs_v2._3} then
ggivCounter := ggivCounter + 1



Mike

 

It worked but this created another problem. Most of the "ggiv" are uppercased. I tried to use the UCase function outside and inside the InStr function, but it didn't work. How can I use the UCase function to pick up the "ggiv" string in caps? Thx.
 
Try this:

if "GGIV" in ucase({TurnOver_Logs_v2._3}) then


Or, if you like using the InStr (extra unsolicited info: you don't need the "1," in the beginning since you are checking the entire string)

if Ucase(InStr({TurnOver_Logs_v2._3}),"GGIV") > 0 then


Naith Mike

 

Looks like I figured it out. The following formula I put in:


WhileReadingRecords;

numberVar ggivCounter;

if InStr(1,UCase({TurnOver_Logs_v2._3}),"GGIV") > 0 then
(
ggivCounter := ggivCounter + 1;
);

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top