To check only one IP address exist in a system.

Friday, March 13, 2009

This codes is to check if the IP adress has been used. If Yes, error message will prompt you upon exiting the IP Address field.

Sub Exiting(Source As Field)
Dim w As New NotesUIWorkspace
Dim uidoc As NotesUIDocument

Set uidoc = w.CurrentDocument

If uidoc.FieldGetText("MachineType") = "Desktop" Or uidoc.FieldGetText("MachineType") = "Server" Then
IP_Address2 = uidoc.FieldGetText("TRNAddr")
key = IP_Address2
End If

If Len(IP_Address2) >= 8 Then
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView

Set db = session.CurrentDatabase

Set view = db.GetView( "svByIPAdd" )
Set doc = view.GetDocumentByKey (key )

If Not (doc Is Nothing) Then
Messagebox "This IP Address has been used."
End If

End If
End Sub

0 comments: