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

IP Address sorting

Status
Not open for further replies.

BrookeSmith

Programmer
Jul 19, 2000
4
US
Anyone tried to store an IP address in any format other than text? Sorting an IP address in text form does not give acceptable results. If the field is formatted as a number only one decimal is allowed. (IP addresses have 3 decimals i.e. 10.7.5.125)   I've tried having each octet as a separate field and this has problems too.
 
I don't have to sort a lot of addresses but I have one application where I need to sort them. I created an input mask like 000.000.000.000. This forces the user to input the leading zeros and it sorts well as text. Probably not what you had in mind but........
 
BrookeSmith,


Here my fix:

In the table design
TCP/IP Address,Text
Format #\.#\.#\.#
Mask !999.999.999.999;0;_

Do the same on the form with decimal set to 0

flh70
 
Rather than storing the whole address in one field, break it up into four number fields. I use this in applications and use fields IPA, IPB, IPC, IPD, then you can sort on each field separately and use a concatenation to put them together for presentation purposes.

Sample Concatenation Function
=[IPA] & "." & [IPB] & "." & [IPC] & "." & [IPD]

This worked like a charm for me. As for entering it in four separate controls, you can use a mask in each text box and when the textbox mask is completed tab automatically to the next field for the user (a la Microsoft TCP/IP Applet in Control Panel).

Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top