473,588 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Importing Excel 2003 to Access 2003

16 New Member
Hi all,
My name is Daniel
Iam trying to learn visual basic and I have been having problems building a marco in Access 2003 that will allow me to extract data from my Excel 2003 spreadsheet into my Access table (fields have the same name, i just need to change the data). The data in the spreadsheet is huge with 32 columns and about 7000 rows. I have tried to wirte code but i keep getting error messages.
Maybe i need to start with something with smaller data.

This is what i have done so far. Does anyone know how to help?


Sub DAOFromExcelToA ccess()
' exports data from the active worksheet to a table in an Access database
' this procedure must be edited before use
Dim db As Database, rs As Recordset, r As Long
Set db = OpenDatabase("C :\FolderName\Da taBaseName.mdb" )
' open the database
Set rs = db.OpenRecordse t("TableName" , dbOpenTable)
' get all records in a table
r = 3 ' the start row in the worksheet
Do While Len(Range("A" & 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("FieldN ame1") = Range("A" & r).Value
.Fields("FieldN ame2") = Range("B" & r).Value
.Fields("FieldN ameN") = Range("C" & 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
db.Close
Set db = Nothing


I would appriciate any help or suggestion
Many Thanks

Regards Daniel
Sep 11 '07 #1
5 1582
VBPhilly
95 New Member
Hi all,
My name is Daniel
Iam trying to learn visual basic and I have been having problems building a marco in Access 2003 that will allow me to extract data from my Excel 2003 spreadsheet into my Access table (fields have the same name, i just need to change the data). The data in the spreadsheet is huge with 32 columns and about 7000 rows. I have tried to wirte code but i keep getting error messages.
Maybe i need to start with something with smaller data.

This is what i have done so far. Does anyone know how to help?


Sub DAOFromExcelToA ccess()
' exports data from the active worksheet to a table in an Access database
' this procedure must be edited before use
Dim db As Database, rs As Recordset, r As Long
Set db = OpenDatabase("C :\FolderName\Da taBaseName.mdb" )
' open the database
Set rs = db.OpenRecordse t("TableName" , dbOpenTable)
' get all records in a table
r = 3 ' the start row in the worksheet
Do While Len(Range("A" & 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("FieldN ame1") = Range("A" & r).Value
.Fields("FieldN ame2") = Range("B" & r).Value
.Fields("FieldN ameN") = Range("C" & 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
db.Close
Set db = Nothing


I would appriciate any help or suggestion
Many Thanks

Regards Daniel
Hello Daniel,
what error are you getting and on what code/line is it erroring at?
Your code looks ok to me, so far. Just need more detail.
Sep 11 '07 #2
Grubsy4u
16 New Member
Well basically when i Press F8 to step through the code i get error signs after the first bit of code.

I'm not sure how to correct it tho?

What should i do?
Sep 12 '07 #3
VBPhilly
95 New Member
Well basically when i Press F8 to step through the code i get error signs after the first bit of code.

I'm not sure how to correct it tho?

What should i do?
an error could be many things. usually when you get an error, a messagebox comes up saying what the error was.
also, note the line of code the error 'breaks' on.
post what you find.
Sep 13 '07 #4
codeCruncher
8 New Member
Hi Daniel! Im having the same problem with my code. Have u tried adding the reference?
Sep 14 '07 #5
Grubsy4u
16 New Member
Many thanks...I have tried adding the reference yet?

I guessing i have made errors cause the data i am trying to import is very huge
Sep 19 '07 #6

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

Similar topics

7
3048
by: Darren | last post by:
I have been attempting to create a reservation planning form in excel that imports Data from an Access database and inserts that information automaticly into the correct spreed sheet and the correct cells within that worksheet. The Excel Book is made up of 12 worksheets named Jan-Dec. Each worksheet has columns labeled as each day of that month. Column 'A' is reserved for 19 rows named "room1 - room19". The data I am importing from the...
8
2536
by: harry | last post by:
Hi Folks: I'm trying to do something that looks simple, but I can't make it work right. It's Access 2000 on a Win2000 computer. I create a database with 5 columbs. The data I need to import is text. The way it's formatted is one line each field, for the 5 fields, then to the next record. The text file looks like this: WPTJ410
1
2449
by: Geoff Jones | last post by:
Hi I have a question which I hope somebody can answer. I have written a VB application with which I want to import an Excel file, analyze the data within it and do some calculations. There are in fact five sheets in the Excel file. My original idea was to import the file into access and create a database file; which I did and worked beautifully. It generated five tables in the database as expected. However, I then thought why not...
5
3160
by: hharriel | last post by:
Hi, I am hoping someone can help me with an issue I am having with excel and ms access. I have collected data (which are in individual excel files) from 49 different school districts. All districts have used the same excel template and populated the same 32 data fields (columns). I created one large excel file from all 49 files which gives me a master table of 60,000 or so records. I have tried to import this master table into access...
1
7610
by: John Overton | last post by:
I have a new requirement to Import and Export Excel tables into and out of Access 2003. The Excel tables are located on a remote server but I know the path to the Excel Files. Can you please help me with the Access VBA code I need to perform these Importing and Exporting tasks?? Sincerely, John Overton
3
5316
by: D.Stone | last post by:
I'm trying to import an Excel spreadsheet into an existing Access table using Office 2003. Ultimately, the plan is to do it programmatically using TransferSpreadsheet, but to check that the file has no problems, I've done it manually with the Import Spreadsheet wizard. The worksheet has 43 rows, and I import a named range defined as "=Sheet1!$C:$E". The import works, but I get a table with 64K rows, all but 43 being blank!
15
16163
by: OfficeDummy | last post by:
Hello all! I searched the Internet and this forum for a similar problem, but I found no help... Also, I'm a complete newbie to the fascinating world of programming, VBA and Access, so my question can very well be very stupid. The tasks are: 1)Import an Excel table into Access 2)Add a new column and fill it with variables of date/time type. Steps 1 and 2 need to be done only once, and I've almost managed to accomplish them. Now...
2
2559
by: lrheeza | last post by:
Hello everyone, I am a newbie at MS Access and I need help!!! I am importing an excel file using Import functionality in MS Access, all the fields are required but there are instances in the excel sheet wherein some of the fields are not populated. The fields that are being imported are: Full Name, first name, last name, initial (optional), userID and email address. How do i inform the users that the following records were not imported...
0
7929
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7862
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8357
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7987
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8223
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5398
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3847
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1196
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.