I wany to record an IP address in access

C

Cider Baby

I want to be able to record a different range of IP addresses for different
types of devices. I want the database to give me the next available IP
address.
 
A

Allen Browne

Use 4 fields of type Byte.
You can print them with dots between the numbers if you wish.

To get the next available number in your form, use the AfterUpdate event
procedure of btye 3 to lookup the maximum number used so far for byte 4.
Example:

Private Sub Byte3_AfterUpdate()
Dim strWhere As String
Dim varResult As Variant

If Not (IsNull(Me.Byte1) Or IsNull(Me.Byte2) Or IsNull(Me.Byte3)) Then
varResult = DMax("Byte4", "Table1", strWhere)
If IsNull(varResult) Then
Me.Byte4 = 0
ElseIf varResult < 255 Then
Me.Byte4 = varResult + 1
End If
End If
End Sub
 

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