M
Marcel
Hello,
I created a table in MSAccess with an index.
When I add rows into this table from VBA-code in Excel, I do not get any
index violation error messages in Excel and the record is not added to the
table!
Why this?
Here my code:
Public Function InsertActivity(person_id As Integer, from_time As Date,
to_time As Date, department As String, job As String, job_number As Integer)
Dim strSQL As String
On Error GoTo Err_AccessDBNotOpen
If (dbsAccessData.name = "dummy") Then ' when DB is not open ->
Exception -> open DB
End If
On Error GoTo Err_InsertActivity
strSQL = "Insert Into tblActivity09 (PersonID, FromTime, ToTime,
Department, Job, JobNumber) Values (" & person_id & ",'" & from_time & "','"
& _
to_time & "','" & department & "','" & job & "'," &
job_number & ")"
dbsAccessData.Execute (strSQL)
Exit Function
Err_AccessDBNotOpen:
Call OpenMSAccessDB
Resume Next
Err_InsertActivity:
MsgBox "InsertActivity()" & vbCrLf & Err.Description & "Error-Number=" &
Err.Number
Exit Function
End Function
I created a table in MSAccess with an index.
When I add rows into this table from VBA-code in Excel, I do not get any
index violation error messages in Excel and the record is not added to the
table!
Why this?
Here my code:
Public Function InsertActivity(person_id As Integer, from_time As Date,
to_time As Date, department As String, job As String, job_number As Integer)
Dim strSQL As String
On Error GoTo Err_AccessDBNotOpen
If (dbsAccessData.name = "dummy") Then ' when DB is not open ->
Exception -> open DB
End If
On Error GoTo Err_InsertActivity
strSQL = "Insert Into tblActivity09 (PersonID, FromTime, ToTime,
Department, Job, JobNumber) Values (" & person_id & ",'" & from_time & "','"
& _
to_time & "','" & department & "','" & job & "'," &
job_number & ")"
dbsAccessData.Execute (strSQL)
Exit Function
Err_AccessDBNotOpen:
Call OpenMSAccessDB
Resume Next
Err_InsertActivity:
MsgBox "InsertActivity()" & vbCrLf & Err.Description & "Error-Number=" &
Err.Number
Exit Function
End Function