hi there here is another question. I have made a form to add records to a table. But i want to disable this possibility in 2 situations;

1. if the textfield is empty
2. if the string in the textfield allready excist as a record in the table.

First i will give you my code

VB Code:
  1. Private Sub cmdLokatie_Click()
  2. Dim doos As Byte
  3.  
  4. If IsNull(Me!lokatieToevoegen) Then
  5. doos = MsgBox("mag geen nul zijn", vbCritical + vbOKOnly, "fout")
  6. Exit Sub
  7. End If
  8.  
  9.  
  10.  
  11.  
  12. Dim rst As New ADODB.Recordset
  13.  
  14. Dim strSQL As String
  15.  
  16. strSQL = "Select * From Lokatie"
  17.  
  18.  
  19.  
  20. rst.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
  21.  
  22.  
  23. With rst
  24.  
  25.     .AddNew
  26.  
  27.     !Lokatie = Me!lokatieToevoegen
  28.        
  29.    .Update
  30.  
  31.     .Close
  32.  
  33. End With
  34.  
  35.  
  36. End Sub

As you can see, i have solved my first problem, but how can i check if the new Item to be added by the user, isn't allready a record in the table, so i can end the procedure with exit sub, en give a msgbox why the new item isnt added?


I hope you can help me