Find Next Available Value

G

Guest

I have a table containing IP Addresses. Each octet (part) of the IP address
is stored in a separate field with the names IPOctet1, IPOctet2, IPOctet3 and
IPOctet4. I want to create a command button that will look at the existing IP
addresses and assign the next available one for that location. The 3 octet of
each address differs by location (i.e. 10.1.30.1 is Location 1, 10.1.45.1 is
Location 2. The next available address must be specific to that location. Any
help is greatly apprecitated!!!


Thanks,

TIm
 
W

Wayne Morgan

See if this will get you started:

Dim intIPOctet As Integer
'Find the current largest IPOctet4 then add 1
intIPOctet=DMax("IPOctet4", "TableName", "IPOctet1=" & Me.txtIPOctet1 & "
And IPOctet2=" & Me.txtIPOctet2 & " And IPOctet3=" & Me.txtIPOctet3) + 1
'255 may be the Broadcast address and not assignable
If intIPOctet > 254 Then
Msgbox "Out of addresses!", vbExclamation + vbOkOnly
Else
'assign the address here
End If
 
J

Jeff C

Tim said:
I have a table containing IP Addresses. Each octet (part) of the IP address
is stored in a separate field with the names IPOctet1, IPOctet2, IPOctet3 and
IPOctet4. I want to create a command button that will look at the existing IP
addresses and assign the next available one for that location. The 3 octet of
each address differs by location (i.e. 10.1.30.1 is Location 1, 10.1.45.1 is
Location 2. The next available address must be specific to that location. Any
help is greatly apprecitated!!!


Thanks,

TIm


Onclick event of the button

Me.[Octet3] = (DMax("Octet3", "thistable")+15)
eg. 10.1.30.1
Find the highest value in the 3rd octet (30) from this table and add 15.
= 10.1.45.1

The 3rd octet is the only one that changes? it always changes by 15?

Hope this Helps,

Jeff C.
 
G

Guest

Jeff, thanks for your help. I tried this method and it did work but actually
it's the 4th Octet that increments not the 3rd and it only increments by 1. I
revised it so that the 4th octet incremented but I ran into a problem. I
don't think I explained it very well in my first post so see if this helps.

IP addresses are broken down into 4 Octets with a period separating each
octet(i.e. 10.0.2.5). With some exceptions, each octet can range from 0 to
254. Some values are reserved (i.e 127.0.0.1) for specific purposes so I
store each octet in it's own field to make testing for valid entries easier.
With networks a portion of the IP address is the network address and part is
the host (computer) address. Kind of like a phone number is broken up by area
codes and city prefixes. So, in my case the first 3 octets is the network
address (i.e. 10.1.1.X) 10.1.1 is the network address. The X is a variable
number that can range from 0 to 254. I have several networks that look like
the following:

Location 1 10.1.1.0
Location 2 10.1.2.0
Location 3 10.1.3.0
and so on...

So... When I click my command button "Next Available Address" it should do
the following. Based on the location I have chosen assign the next available
address for that network. It dosen't necessarly have to be after the largest
value. It can be any address as long as it is not already in use. For example
suppose Location 3 has
10.1.3.1, 10.1.3.2, 10.1.3.4 and 10.1.3.6 already assigned. Then 10.1.3.3 or
10.1.3.7 would both be acceptable.

I hope I have explained this well. Kind of a challenge. Let me know if you
need further clarification. Thanks so much for your help!!!



Jeff C said:
Tim said:
I have a table containing IP Addresses. Each octet (part) of the IP address
is stored in a separate field with the names IPOctet1, IPOctet2, IPOctet3 and
IPOctet4. I want to create a command button that will look at the existing IP
addresses and assign the next available one for that location. The 3 octet of
each address differs by location (i.e. 10.1.30.1 is Location 1, 10.1.45.1 is
Location 2. The next available address must be specific to that location. Any
help is greatly apprecitated!!!


Thanks,

TIm


Onclick event of the button

Me.[Octet3] = (DMax("Octet3", "thistable")+15)
eg. 10.1.30.1
Find the highest value in the 3rd octet (30) from this table and add 15.
= 10.1.45.1

The 3rd octet is the only one that changes? it always changes by 15?

Hope this Helps,

Jeff C.
 
G

Guest

Ooops forgot to explain the problem I ran into. While the code worked. It
would increment the last octet based on the highest value in any location. I
need it to be only for that particular location. For example

I have:

10.1.3.2
10.1.6.1
10.1.2.41
10.1.8.20

and I am in location 3. I get the new value: 10.1.3.42 because the higest
value for octet 4 is 41. What I want to get is 10.1.3.3. Make sense?

Thanks!!

Jeff C said:
Tim said:
I have a table containing IP Addresses. Each octet (part) of the IP address
is stored in a separate field with the names IPOctet1, IPOctet2, IPOctet3 and
IPOctet4. I want to create a command button that will look at the existing IP
addresses and assign the next available one for that location. The 3 octet of
each address differs by location (i.e. 10.1.30.1 is Location 1, 10.1.45.1 is
Location 2. The next available address must be specific to that location. Any
help is greatly apprecitated!!!


Thanks,

TIm


Onclick event of the button

Me.[Octet3] = (DMax("Octet3", "thistable")+15)
eg. 10.1.30.1
Find the highest value in the 3rd octet (30) from this table and add 15.
= 10.1.45.1

The 3rd octet is the only one that changes? it always changes by 15?

Hope this Helps,

Jeff C.
 
G

Guest

Wayne, I think this may be working but I need help figuring out how to assign
the number once the value has been calculated.

Thanks a bunch!
 
W

Wayne Morgan

To assign the value, place the value in the textbox for the 4th octet. This
will assign that value for the current record. If you want to assign it
somewhere else, let me know.

Example:
Me.txtIPOctet4 = intIPOctet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top