In the following code, it is not letting me delete the entire contents of a table. The user id and password I supply in the connection string DO give me permission to do so (since I can just go into the database and blow the rows away). What could be wrong? FYI, the database prompts you for a user name and password whenever you open it.
Sub UpdateTables()
Dim cnnCon As New Connection
Dim strCon As String
Dim rstCustomers As New Recordset
Dim rstHardware As New Recordset
Dim rstHospitalSys As New Recordset
Dim rstSpecialist As New Recordset
On Error GoTo ErrorHandler
strCon = "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=C:\Backups\controltex database 97.mdb;" & _
"Uid=*****;" & _ 'assume valid username
'and password are here
"Pwd=*****;"
cnnCon.Open strCon
Set rstCustomers = New ADODB.Recordset
'Problem here
rstCustomers.Open "customers", strCnn, , , adCmdTable
rstCustomers.Delete adAffectAll
ErrorHandler:
MsgBox Err
Resume Next
'First error is 3001, then 3704, then 0, then 20
End Sub
Sub UpdateTables()
Dim cnnCon As New Connection
Dim strCon As String
Dim rstCustomers As New Recordset
Dim rstHardware As New Recordset
Dim rstHospitalSys As New Recordset
Dim rstSpecialist As New Recordset
On Error GoTo ErrorHandler
strCon = "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=C:\Backups\controltex database 97.mdb;" & _
"Uid=*****;" & _ 'assume valid username
'and password are here
"Pwd=*****;"
cnnCon.Open strCon
Set rstCustomers = New ADODB.Recordset
'Problem here
rstCustomers.Open "customers", strCnn, , , adCmdTable
rstCustomers.Delete adAffectAll
ErrorHandler:
MsgBox Err
Resume Next
'First error is 3001, then 3704, then 0, then 20
End Sub