I have a project that I'm changing from DAO 3.51 jet to ADO
The on error resume next doesn't work. In the old access when I did an object.addnew then object.update, I could set on error resume next and check the error code after the update to determine if a duplicate key was found.
Now, it gives a fatal run-time error on the update method and doesn't continue to the next statement. What is up?
I'm using VB6 connecting to an Access 2000 .mdb
The table has a primary key and 2 other indexes.
The connection string is:
accessconnect = "Provider=MSDASQL.1;" & _
"Persist Security Info=False;" & _
"Extended Properties=" & """" & _
"DSN=MS Access Database;" & _
"DBQ=" & fulldsn & ";" & _
"DefaultDir=" & currdrivepath & ";" & _
"UID=admin;PWD=;" & _
"DriverId=25;FIL=MS Access;" & """"
Here's the code. It errors before executing the "if err.number" statement saying I am trying to create duplicate key. I want to trap that myself.
nixdtbl.Close
Set nixdtbl = New ADODB.Recordset
nixdtbl.Open "nixdates", Umpmain.Conn1, adOpenDynamic, adLockOptimistic, adCmdTableDirect
nixdtbl.AddNew
nixdtbl("NixUmp_id" = umptbl("Umpnum"
nixdtbl("NixDate" = CDate(datelist.Text)
nixdtbl("Nixgame" = 0
nixdtbl("Nixfield" = 0
On Error Resume Next
nixdtbl.Update
If Err.Number = 3022 Then
MsgBox "Already blocked this date."
Err.Clear
nixdtbl.CancelUpdate
Exit Sub
End If
The on error resume next doesn't work. In the old access when I did an object.addnew then object.update, I could set on error resume next and check the error code after the update to determine if a duplicate key was found.
Now, it gives a fatal run-time error on the update method and doesn't continue to the next statement. What is up?
I'm using VB6 connecting to an Access 2000 .mdb
The table has a primary key and 2 other indexes.
The connection string is:
accessconnect = "Provider=MSDASQL.1;" & _
"Persist Security Info=False;" & _
"Extended Properties=" & """" & _
"DSN=MS Access Database;" & _
"DBQ=" & fulldsn & ";" & _
"DefaultDir=" & currdrivepath & ";" & _
"UID=admin;PWD=;" & _
"DriverId=25;FIL=MS Access;" & """"
Here's the code. It errors before executing the "if err.number" statement saying I am trying to create duplicate key. I want to trap that myself.
nixdtbl.Close
Set nixdtbl = New ADODB.Recordset
nixdtbl.Open "nixdates", Umpmain.Conn1, adOpenDynamic, adLockOptimistic, adCmdTableDirect
nixdtbl.AddNew
nixdtbl("NixUmp_id" = umptbl("Umpnum"
nixdtbl("NixDate" = CDate(datelist.Text)
nixdtbl("Nixgame" = 0
nixdtbl("Nixfield" = 0
On Error Resume Next
nixdtbl.Update
If Err.Number = 3022 Then
MsgBox "Already blocked this date."
Err.Clear
nixdtbl.CancelUpdate
Exit Sub
End If