473,405 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Insert or Update excel data to Access table via VBA

67 64KB
Hi,

I would like to insert data from excel to access table. This is the code that I use to write data from excel to access
Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferSpreadsheet acImport, , tableName, filePath, True, range:="Sheet1!A:" & endCol
But how to update if record already exist in access table, and if it is not exist, then insert directly?

Best regards,
Sophanna
Jun 1 '14 #1
5 5349
jimatqsi
1,271 Expert 1GB
Sophanna,
By changing 'acImport' in that code to 'acLink' (and providing a new, temporary table name) you will add the Excel sheet to your DB, and it will look like a table. You can run a query against it just like a table. So link the spreadsheet, write an update query (or write some VB code to accomplish same) and you're done.

Jim
Jun 1 '14 #2
sophannaly
67 64KB
Hi Jim,

Thanks you so much for reply. So to do this, after importing this spreadsheet to temporary table with code DoCmd.TransferSpreadsheet, then the next line code is a query about updating data from this temp table to existing table.

Is it what solve this issue?

Best regards,
Sophanna
Jun 1 '14 #3
NeoPa
32,556 Expert Mod 16PB
The steps are the right ones Sophanna. Clearly, you must do each step correctly, but if you do that then it should work.
Jun 1 '14 #4
sophannaly
67 64KB
@NeoPa, @Jim thanks you guys so much for reply. I will give a try and will come back if I have problem.
Jun 4 '14 #5
NeoPa
32,556 Expert Mod 16PB
Let us know if it works too Sophanna, then I can make sure Jim's post is flagged as Best Answer.
Jun 4 '14 #6

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

Similar topics

3
by: king | last post by:
Anyone know if there is method that can insert all record from a table in an MS Access 2000 database to a table in MS SQL Server 2000 database by a SQL statement? (Therefore, I can execute the...
2
by: VM | last post by:
What's the fastest way to insert data into an Access table? I'm currently using ExecuteNonQuery but it seems to take too long (should filling an mdb table be slower than filling a datatable?). So...
3
by: Santa-D | last post by:
I've got an excel sheet that I need to import into a table, however, I want the function to automatically manipulate the data prior to it being imported. For example, i have a field called and...
4
MitchR
by: MitchR | last post by:
Good Morning; I have an issue that I need to guidance to resolve. I have a table called return_tbl with about 25k records. I have 23 Fields in this table. I am looking to update 3 of these 23...
1
by: dbalan | last post by:
I have excel file where the data is in horizontal manner. I have an output in access table, in vertical manner. I have a snap shot of data which I would like to attach which better describes my...
1
by: vdama | last post by:
Hi, I am using MS-Access as back end table for VB application. In the access table there are four columns as sno,productioncount ,percentage and totalcount. Here in prodcution count filed we have...
11
by: cooperkuo | last post by:
Dear all, I have a question about ADO in the subform. I know how to use ADO to insert/update/select data into the sigin form, but wehn I try to do it in the form with subform((Datasheet). I don't...
12
by: anand padia | last post by:
I have a master access table where we store all the employee information. I have various application developed in excel which imports and uses information in master. Now I want to develop a excel...
0
by: Sofi02 | last post by:
The following is the html page where number of rooms are mention i need to update MS access table depending on the number of rooms selected hotel.html <html> <head> <script> function...
1
by: manikandanc | last post by:
if i tying to insert the values in access table not showing any error but also not saving the values in table. plz,Help.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...

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.