In the following code , I want to check if the number which I enter in column(0) of DBGrid1 has already entered before in this column or not . column(0) correspond the field “ID” in my Access Table.
Private Sub DBGrid1_AfterColEdit(ByVal ColIndex As Integer)
Dim SW As Integer
If Me.DBGrid1.Col = 0 Then
SW = Me.DBGrid1.Columns(0).Value
M = Me.Adodc1.Recordset.RecordCount
For i = 1 To M
If SW = Me.Adodc1.Recordset!ID Then
MsgBox "This code is in use ", , "Error"
Whenever I put any NEW or USED number in column(0) , it gives me the message !!!
Please help me by amending this code to check if the data I enter is in the field “ID” or not.