473,473 Members | 4,189 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Run time error from Excel to access ?

1 New Member
I am receiving the following error:

Microsoft Visual Basic

Run-Time error '2147467259 (80004005)':

The microsoft jet database engine cannot open the file. It is already opened exclusively by another user, or you need permission to view its data.

This is the code I am using, the following is assigned to a button which should send data through to an access table, however works for me, but when other users try it they get the above message ?

Sub ADOFromExcelToAccess()
' exports data from the active worksheet to a table in an Access database
' this procedure must be edited before use
Dim cn As ADODB.Connection, rs As ADODB.Recordset, r As Long
' connect to the Access database
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=S:\Real Time Data\Sales.mdb;"
' open a recordset
Set rs = New ADODB.Recordset
rs.Open "Table2", cn, adOpenKeyset, adLockOptimistic, adCmdTable
' all records in a table
r = 1 ' the start row in the worksheet
Do While Len(Range("B" & r).Formula) > 0
' repeat until first empty cell in column A
With rs
.AddNew ' create a new record
' add values to each field in the record
.Fields("Personnel No") = Range("B" & r).Value
.Fields("Date / Time") = Range("C" & r).Value
.Fields("Product") = Range("D" & r).Value
.Fields("Qte") = Range("E" & r).Value
.Fields("Pol / Qte No") = Range("F" & r).Value
.Fields("B") = Range("G" & r).Value
.Fields("C") = Range("H" & r).Value
.Fields("ADB") = Range("I" & r).Value
.Fields("ADC") = Range("J" & r).Value
.Fields("PP") = Range("K" & r).Value
.Fields("HE") = Range("L" & r).Value
.Fields("LEG") = Range("M" & r).Value
.Fields("NA(NOISE)") = Range("N" & r).Value
.Fields("TRM4") = Range("O" & r).Value
.Fields("TRAVEL ONLY") = Range("P" & r).Value
.Fields("Outcome") = Range("Q" & r).Value
.Fields("Call Source") = Range("R" & r).Value
.Fields("Call Outcome") = Range("S" & r).Value
.Fields("Our Price") = Range("T" & r).Value
.Fields("Comp Price") = Range("U" & r).Value
.Fields("Comp Name") = Range("V" & r).Value
.Fields("Time") = Range("W" & r).Value
' add more fields if necessary...
.Update ' stores the new record
End With
r = r + 1 ' next row
Loop
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
Dec 13 '07 #1
0 1235

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: Ange T | last post by:
Hi there, I'm having pain with the VB behind an Access form. The form is used to create reports in Excel based on the details entered in the form. This has always worked without error on my...
2
by: Steve Miller | last post by:
hello... i am a 'user' of access, meaning, i import excel files, join, and merge....that's about the extent of my expertise with ms-access. my boss wants me to create an access application that...
4
by: Polly | last post by:
I had a macro that ran a parameter query and created and opened an Excel file with the system date as part of the file name, but I had to change the file name by hand. So I converted the macro to...
2
by: dailem | last post by:
I have a bit of code tied to a command button in Access that runs a query then transfers it to a new Excel worksheet (& new file). It works fine EVERY OTHER TIME THAT I RUN IT....what the 'heck...
8
by: Nick M | last post by:
Hello All, Excellent info here Thanks! I am very new to using access in general and I am on a learning curve. I'm trying to import an excel workbook (with worksheets) into an access db via a...
1
by: sk | last post by:
Please forgive me if the same topic is already posted. But i havent found I have got an error while accessing the excel file as below. Can somebody reply if there is a solution Access is denied....
0
by: zfraile | last post by:
I'm getting this error from the JIT compiler at runtime, but only on my boss' machine, not my development machine. I believe the error is generated from a call to an Excel object, but I can't tell...
25
by: dennijr | last post by:
ok, shell always used to be easy for me, now its starting to get annoying cause i dont know wats wrong heres the simplist code possible: Private Sub IExplorer_Click() a = Shell("C:\Program...
4
by: Brian | last post by:
I have a 2000/2002 Access db that I use to collect and store my exercisetime using a form to enter. I wanted to see a summary of the total timefor each exercise so I have a subform that does this....
15
by: r90slash6 | last post by:
Hi Guys, I have code for click event on an Access form that opens an Excel file, refreshes data of a pivot table on the active worksheet and then filters records based on a criteria. Everything...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.