how do you count instances within a field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

say you have a field "Mr. and Mrs. John Smith", is there a function which
will tell you the number of spaces, in this case: 4.

I use instr() frequently, but that only figures first instance position.

thanks.
 
tgl said:
say you have a field "Mr. and Mrs. John Smith", is there a function which
will tell you the number of spaces, in this case: 4.

I use instr() frequently, but that only figures first instance position.

thanks.

How about this:

Len([my_field]) - Len(Replace([my_field]," ",""))
 
Brian,
Very creative!

--
Duane Hookom
MS Access MVP
--

Brian said:
tgl said:
say you have a field "Mr. and Mrs. John Smith", is there a function which
will tell you the number of spaces, in this case: 4.

I use instr() frequently, but that only figures first instance position.

thanks.

How about this:

Len([my_field]) - Len(Replace([my_field]," ",""))
 
That should work, though i do think there should be a function to count
instances in a field, don't you? seems basic.
thanks!

Duane Hookom said:
Brian,
Very creative!

--
Duane Hookom
MS Access MVP
--

Brian said:
tgl said:
say you have a field "Mr. and Mrs. John Smith", is there a function which
will tell you the number of spaces, in this case: 4.

I use instr() frequently, but that only figures first instance position.

thanks.

How about this:

Len([my_field]) - Len(Replace([my_field]," ",""))
 
tgl said:
That should work, though i do think there should be a function to count
instances in a field, don't you? seems basic.
thanks!

Not really. If there were a string function for everything that someone,
somewhere thought might be useful then there would be thousands of 'em!
 
Back
Top