Private Sub Command9_Click()
If checkVal Then
MsgBox "Value exists"
Exit Sub
Else
If Me.Field3.Value = "inactive" Then
MsgBox "you can't add in-active location", vbCritical
Exit Sub
Else
Forms!form1.MyListbox.AddItem Item:=Me.ID.Value & ";" & Me.Field1.Value & ";" & Me.Field2.Value
End If
End If
End Sub
Function checkVal() As Boolean
Dim x As Integer, [COLOR="Blue"]myValue As Integer[/COLOR]
For x = 0 To Forms!form1.MyListbox.ListCount - 1
[COLOR="Blue"] myValue = Forms!form1.MyListbox.Column(0, x)
If Forms!form1.MyListbox.Column(0, x) = myValue Then
checkVal = True[/COLOR]
Exit Function
End If
Next x
End Function