hi
i having trouble with saving and checking duplicate with my coding..i can't save my data and when i save a new data , it's always say duplicate..i want to save my new data and if it record is already have it, want to show a msgbox saying duplicate..here my coding..please help if u can
Dim strrs As New ADODB.Recordset
Private Sub cmdadd_Click()
On Error Resume Next
Set strrs = New ADODB.Recordset
If (txtempid.Text = "" Or txtempid.Text = Null) Or (txtempname.Text = "" Or txtempname.Text = Null) Or (cbodep.Text = "" Or cbodep.Text = Null) Or (cboorg.Text = "" Or cboorg.Text = Null) Or (cborole.Text = "" Or cborole.Text = Null) Then
MsgBox "Do Not Let The Data Empty,Fill Again", vbInformation, "Please Fill All Data"
txtempid.SetFocus
Exit Sub
Else
strrs.MoveFirst
While strrs.EOF = False
If Val(txtempid.Text) = strrs!Employee_ID Then
MsgBox "RECORD ALREADY EXISTS!", vbOKOnly + vbInformation, "Duplicate Record"
txtempid.SetFocus
Exit Sub
End If
strrs.MoveNext
Wend
strrs.AddNew
strrs!Employee_ID = txtempid.Text
strrs!Employee_Name = txtempname.Text
strrs!Department_Name = cbodep.Text
strrs!Organization_Name = cboorg.Text
strrs!Role_Name = cborole.Text
txtempid.Text = ""
txtempname.Text = ""
cbodep.Text = ""
cboorg.Text = ""
cborole.Text = ""
strrs.Update
MsgBox "One record have saved & applied in database!", vbOKOnly + vbInformation, "Saving Data"
End If
End Sub