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

Text Manipulation?

Status
Not open for further replies.

tyleri

Programmer
Jan 2, 2001
173
0
0
US
I have a rather confusing dilemna. I have this list of IP addresses in a field, and the only set of characters I need is the 3rd group of numbers.

So - here is an example of what I'm talking about:

1.24.100.23
245.2.100.254
23.243.100.2
123.234.100.123

for every single one of those, I want to only grab the 3 characters: 100

it's not as simple as this - because the 100 place could be any number - whether it be a single-digit or a three-digit number.

Does anyone know how I can go about selecting JUST the 3rd tier of the IP Address with expressions in queries? I can do this in Excel by concatenating the text by period, but I would like to automate this in access.

ANy clues?
 
Try something like the following - I know it looks like a mess but here it goes - I did this in a query and used the Mid and InStr functions.

Mid([IP],InStr(InStr(1,[IP],".")+1,[IP],".")+1,3)

Breaking it apart:
What this does is searches for the 1st position where there is a persiod - InStr(1,[IP],".")

Then searches for the position of the second period (STARTPOS) - InStr(InStr(1,[IP],".")+1,[IP],".")

Then it grabs the 3 charachters from that starting point - mid([IP],STARTPOS + 1, 3)

I hope this wasn't too confusing! [bugeyed] Scott Musich
Database Analyst/Programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top