Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2005

    Unanswered: Double click for next value

    on a table I record IP addresses that start at

    so it would like this

    I would like to be able to double click the IP field text box and for the database to say the next ip address availeble is would you like to use this?

    The second thing i would like the code to do is to use any addresses that arnt part of the sequence where they might have been deleted ie if the sequence looked like this

    when double click is applyed the next value should be

    any help would be greatley appreciated

  2. #2
    Join Date
    Dec 2004
    Madison, WI
    Maybe this bit of ADO code will work. It assumes you've defined the IPAddress field as a string. If you have blank IPAddresses, you need to change the FollowNumber = 4 to the first number matching your first IP address counting in the blank spaces first. Calling this function will return the next value in your string which you can get on your click of the button by using an expression like msgbox " My Next IP = "192.168.0." & NextIPNum. You can also use it in other places or expressions.

    Function NextIPNum() As String
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    Dim IP As Integer
    Dim FollowNumber As Integer
    FollowNumber = 4
    Dim strSQL As String
    strSQL = "Select IPAddress from Customers Order By IPAddress Asc"
    rs.Open strSQL, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
    If rs.EOF And rs.BOF Then
    MsgBox "No Records"
    Set rs = Nothing
    Do While Not rs.EOF
    If IsNull(rs!IPAddress) Or rs!IPAddress = "" Then GoTo Nxt
    IP = CInt(Right(rs!IPAddress, Len(rs!IPAddress) - InStr(rs!IPAddress, "0.") - 1))
    If IP <> FollowNumber Then
    NextIPNum = FollowNumber
    MsgBox "The next IP Avialable is: " & NextIPNum
    set rs = nothing
    Exit Function
    FollowNumber = FollowNumber + 1
    End If
    End If
    NextIPNum = FollowNumber
    MsgBox "The next IP Avialable is: " & NextIPNum
    set rs = nothing

    End Function
    Last edited by pkstormy; 10-05-06 at 19:52.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts