LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default No Index Violation when adding data in Acccess from Excel

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


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding rows to the data array used in an Index function Lanhing Excel Discussion (Misc queries) 1 April 7th 09 07:45 PM
Excel Access Violation Chris Excel Programming 0 May 14th 08 03:03 PM
data pulling with sharing violation Stonewall Rubberbow Excel Programming 1 April 23rd 08 06:32 PM
sharing violation while saving file after adding this macro Mike Molyneaux Excel Programming 0 March 1st 06 05:20 PM
Unwanted MS Acccess Query in Excel spreadsheet den Excel Programming 1 July 23rd 03 04:47 PM


All times are GMT +1. The time now is 11:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"