I'm still getting a syntax error paul..
tried changing the '.' to "." for string? but still doesnt
work...
save me...
jon
-----Original Message-----
Oops...should have done it this way:
Token1: CInt(GetToken([IP Addr Table].[IP Address],'.',1))
Paste this into field row exactly as shown.
Assuming the IP address is 192.168.1.2, this will give
you 198 in a column
by itself.
Token2: CInt(GetToken([IP Addr Table].[IP
Address],'.',2)) will give you
168...repeat for other columns
--
Paul Overway
Logico Solutions, LLC
www.logico-solutions.com
damn you are good!
appreciate all the help!
have done the module. no prob cutting and pasting..
i assume access automatically calls the function from
there?
in my query of my table, i have tried to input in the
field row,
Token1: GetToken([IP Address],".",1) as "IP Address" is
the field name in the column of ip addresses in my
table.
i get an error msg "Syntax error(comma)in query
expression
'[IP Addr Table].[GetToken([IP Address],"].[",1)]'.
any idea how to solve this? thanks again!
ps:what do you mean by repeating for each token? I only
have one column of ip addresses and only the last 3
numbers are different.
pps: would love to tok to you over email. do drop by.
jon
-----Original Message-----
Take the code below and paste it into a module. The
function below is a
little more flexible than what was on the web page I
referred you to:
In your query, create a new column with the following
expression:
Token1: GetToken([YourFieldWithIPAddressHere],".",1)
Repeat for each token, changing the number/position.
You can then sort on the token(s). BTW...it isn't
necessary that you show
the token columns.
'CODE START
Function GetToken(ByVal Arg As Variant, Separator As
String, Indx As
Integer)
'Returns the nth word in a specific field.
Dim intStartPos As Integer, intEndPos As Integer
Dim intCount As Integer, intSepCount As Integer
Dim strTemp As String
For intCount = 1 To Len(Arg)
If Mid(Arg, intCount, 1) = Separator Then
intSepCount = intSepCount + 1
End If
Next
If Indx > intSepCount + 1 Then
GetToken = Null
Exit Function
End If
intStartPos = 1
For intCount = 2 To Indx
intStartPos = InStr(intStartPos, Arg,
Separator)
+ 1
Next intCount
intEndPos = InStr(intStartPos, Arg, Separator) - 1
If intEndPos <= 0 Then intEndPos = Len(Arg)
GetToken = Trim(Mid(Arg, intStartPos, intEndPos -
intStartPos + 1))
End Function
'CODE END
--
Paul Overway
Logico Solutions, LLC
www.logico-solutions.com
thanks! but where and how do i input the code? is it
a
macro? do i need to create a assess page to do it?
-----Original Message-----
You need to tokenize the string, and then sort on
the
tokens (as numeric).
You are doing right to store in text data
type...really
no choice in the
matter.
See
http://www.mvps.org/access/strings/str0003.htm
for
example of how to
tokenize strings.
--
Paul Overway
Logico Solutions, LLC
www.logico-solutions.com
message
Hi,
Anyone knows how to input an IP address and then
ensure
that i can sort it in the proper ascending or
decending
order? what data type shld i use? am currently
using
the "text" data type as its definitely not a
number.
the dotted decimal form prevents me from sorting
in
the
correct order i need it in.
for eg. I have a block of 137.53.44.XXX addresses
to
manage and i need to arrange the last 3 numbers in
the
proper sequence.
pls help! thanks lots in advance!
jon
.
.
.