hi vb master good day! i just wanted to ask for some help here.. i'am trying to prevent duplcation of records that will be save in my table...
here my code:
the scenario is this eventhough my table doesnt have any records on it, still my system goes popping a mesage that the records i want to verify or save is already existed, i know theres something with my code. I assme that i doesnt actually loking in my database like i want,, kidly take a look at my code and i hope somebody can figure out whats wrong with it!!! Thank you very much!
here my code:
Code:
Private Sub cmdVerify_Click()
Dim rsShowRec As New ADODB.Recordset
Dim cnn As New ADODB.Connection
Set cnn = New ADODB.Connection
cnn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "\dbTimeScheduling2.mdb;"
cnn.Open
For x = 0 To 3
On Error Resume Next
rsShowRec.Open "Select * from RECORDS , cnn, adOpenStatic, adLockOptimistic"
If rsShowRec.EOF <> True Then
If Combo1(x).Text = rsShowRec.Fields("TIME START").Value And Combo4(x).Text = rsShowRec.Fields("TIME END").Value And Combo2(x).Text = rsShowRec.Fields("ROOM").Value And Combo3(x).Text = rsShowRec.Fields("DAYS").Value Then
rsShowRec.Close
cnn.Close
cmdSave.Visible = False
Else
cmdSave.Visible = True
End If
End If
Next
MsgBox ("Records already existed"), vbCritical
End Sub
Comment