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:
Private Sub cmdLokatie_Click() Dim doos As Byte If IsNull(Me!lokatieToevoegen) Then doos = MsgBox("mag geen nul zijn", vbCritical + vbOKOnly, "fout") Exit Sub End If Dim rst As New ADODB.Recordset Dim strSQL As String strSQL = "Select * From Lokatie" rst.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic With rst .AddNew !Lokatie = Me!lokatieToevoegen .Update .Close End With 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




Reply With Quote