Hi there,
I want the program to give me a msg if you either enter a duplicate ID or no ID at all.
If i run the program like this it always gives me the MsgBox "ID exits, cannot duplicate", even though i enter a totaly new ID. If i enter no ID it also gives me the same message.
If i enter the parts that is commented out and also change all my rs to rsp it gives me a error msg "No value given for one or more required parameters" all though all the textboxes have info in them.
My DB is an Access database.
If txtOther(0).Text <> "" Then
'Dim rsp as New Recordset
'rsp.Open "Select * from School where ID=" & txtOther(0).Text, cnPass,adOpenKeyset, adLockOptimistic
If rs.RecordCount = 0 Then
rs.AddNew
rs![ID] = txtOther(0).Text
rs![Name] = txtOther(1).Text
rs![Age] = txtOther(2).Text
rs![Salary] = txtOther(3).Text
rs.Update
' rs.Close
Else
MsgBox "ID exits, cannot duplicate", vbCritical, "Duplication"
End If
Else
MsgBox "Empty field/s found", vbCritical, "Empty field/s"
End If
Thank you in advance
Regards
Gimly
I want the program to give me a msg if you either enter a duplicate ID or no ID at all.
If i run the program like this it always gives me the MsgBox "ID exits, cannot duplicate", even though i enter a totaly new ID. If i enter no ID it also gives me the same message.
If i enter the parts that is commented out and also change all my rs to rsp it gives me a error msg "No value given for one or more required parameters" all though all the textboxes have info in them.
My DB is an Access database.
If txtOther(0).Text <> "" Then
'Dim rsp as New Recordset
'rsp.Open "Select * from School where ID=" & txtOther(0).Text, cnPass,adOpenKeyset, adLockOptimistic
If rs.RecordCount = 0 Then
rs.AddNew
rs![ID] = txtOther(0).Text
rs![Name] = txtOther(1).Text
rs![Age] = txtOther(2).Text
rs![Salary] = txtOther(3).Text
rs.Update
' rs.Close
Else
MsgBox "ID exits, cannot duplicate", vbCritical, "Duplication"
End If
Else
MsgBox "Empty field/s found", vbCritical, "Empty field/s"
End If
Thank you in advance
Regards
Gimly