how do you count instances within a field

T

tgl

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.
 
B

Brian

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]," ",""))
 
D

Duane Hookom

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]," ",""))
 
T

tgl

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]," ",""))
 
B

Brian

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!
 
Top