473,387 Members | 1,512 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,387 software developers and data experts.

Import and append spreadsheet with multiple tabs with button

I have a spreadsheet that has 3 tabs each of the worksheets is setup exactly
like a cooresponding table in Access. I created a button that should import
each tab to a new table and then append those records in the new table to the
cooresponding table. Here is my code for the button:

----(start of code)-----------------------------------------------------------
-------------------------------------------------------------------

Private Sub cmdImportClaim_Click()
On Error GoTo Err_cmdImportClaim_Click
DoCmd.TransferSpreadsheet acImport, , "Import: tblClaim", "C:\Documents
and Settings\cau1042\Desktop\Database Backup\AUTAC Tables Backup\AUTAC
Warranty Claim Import.xls", -1, "tblClaim"

Dim stDocName As String

stDocName = "Append: tblClaim"
DoCmd.OpenQuery stDocName, acNormal, acEdit

DoCmd.TransferSpreadsheet acImport, , "Import: tblPartPerClaim", "C:\
Documents and Settings\cau1042\Desktop\Database Backup\AUTAC Tables Backup\
AUTAC Warranty Claim Import.xls", -1, "tblPartPerClaim"

Dim stDocNameB As String

stDocNameB = "Append: tblPartPerClaim"
DoCmd.OpenQuery stDocNameB, acNormal, acEdit


DoCmd.TransferSpreadsheet acImport, , "Import: tblJobCodesPerClaim", "C:\
Documents and Settings\cau1042\Desktop\Database Backup\AUTAC Tables Backup\
AUTAC Warranty Claim Import.xls", -1, "tblJobCodesPerClaim"

Dim stDocNameC As String

stDocNameC = "Append: tblJobCodesPerClaim"
DoCmd.OpenQuery stDocNameC, acNormal, acEdit

DoCmd.Close
DoCmd.OpenForm "frmClaim"
Exit_cmdImportClaim_Click:
Exit Sub

Err_cmdImportClaim_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmdImportClaim_Click

End Sub
------------------------------------------------------------------------------
----------------------------------------------(end of code)
Each time I press the button it imports and appends the first tab, but it
will not do the same for the other 2 tabs.

The error message I get is some kind of error saying that "tblPartPerClaim"
not found. This tab is spelled correctly in my Excel spreadsheet and in the
database. I can't figure out why it can't see these other 2 tabs.
Any help would be greatly appreciated.

Shannan

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200606/1
Jun 29 '06 #1
1 5348
Nevermind, I figured out my problem. I had to select the cells on the other
worksheet tabs and name each of those selections "tblClaim",
"tblPartPerClaim","tblJobCodesPerClaim". You can do this by clicking in the
name dialog box in Excel (upper left hand corner) and typing a name and
pressing return.

Shannan

socasteel21 wrote:
I have a spreadsheet that has 3 tabs each of the worksheets is setup exactly
like a cooresponding table in Access. I created a button that should import
each tab to a new table and then append those records in the new table to the
cooresponding table. Here is my code for the button:

----(start of code)-----------------------------------------------------------
-------------------------------------------------------------------

Private Sub cmdImportClaim_Click()
On Error GoTo Err_cmdImportClaim_Click

DoCmd.TransferSpreadsheet acImport, , "Import: tblClaim", "C:\Documents
and Settings\cau1042\Desktop\Database Backup\AUTAC Tables Backup\AUTAC
Warranty Claim Import.xls", -1, "tblClaim"

Dim stDocName As String

stDocName = "Append: tblClaim"
DoCmd.OpenQuery stDocName, acNormal, acEdit

DoCmd.TransferSpreadsheet acImport, , "Import: tblPartPerClaim", "C:\
Documents and Settings\cau1042\Desktop\Database Backup\AUTAC Tables Backup\
AUTAC Warranty Claim Import.xls", -1, "tblPartPerClaim"

Dim stDocNameB As String

stDocNameB = "Append: tblPartPerClaim"
DoCmd.OpenQuery stDocNameB, acNormal, acEdit


DoCmd.TransferSpreadsheet acImport, , "Import: tblJobCodesPerClaim", "C:\
Documents and Settings\cau1042\Desktop\Database Backup\AUTAC Tables Backup\
AUTAC Warranty Claim Import.xls", -1, "tblJobCodesPerClaim"

Dim stDocNameC As String

stDocNameC = "Append: tblJobCodesPerClaim"
DoCmd.OpenQuery stDocNameC, acNormal, acEdit

DoCmd.Close
DoCmd.OpenForm "frmClaim"
Exit_cmdImportClaim_Click:
Exit Sub

Err_cmdImportClaim_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmdImportClaim_Click

End Sub
------------------------------------------------------------------------------
----------------------------------------------(end of code)

Each time I press the button it imports and appends the first tab, but it
will not do the same for the other 2 tabs.

The error message I get is some kind of error saying that "tblPartPerClaim"
not found. This tab is spelled correctly in my Excel spreadsheet and in the
database. I can't figure out why it can't see these other 2 tabs.

Any help would be greatly appreciated.

Shannan


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200606/1
Jun 29 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fred | last post by:
Hi. How do I import while mapping an excel table to an access table please??? I've searched around and all I can find is a software product or code that does the same thing as the access...
4
by: Martin | last post by:
There is an Access table on the network. 15 users who do not have Access are connected to the network. Is there a way for each user to be able to enter one or more rows containing 3 or 4 columns to...
5
by: Colleyville Alan | last post by:
I need to import a spreadsheet into an Access table. The spreadsheet has performance for mutual funds for various periods. The problem is that if there is no info for a particular period, the...
15
by: daniroy | last post by:
Hello everybody, your help will be very very welcome on a very classic question... I have some Excell Macro background, a little bit of VBA knowledge. I import daily from Internet series of...
3
by: wildbill | last post by:
I have an Excel spreadsheet with 1000+ rows that I need to import into an Access 2002 db once a month or so. I then need to use that information to update any existing records(multiple fields may...
2
by: madeleine | last post by:
I'm hoping the answer to this is that I'm just doing something silly, but I'm really scratching my head over this one. I'm importing data from multiple workbooks, each workbook has a sheet called...
7
by: Pete | last post by:
I need to import multiple tab delimited files for which I do not have the formats. All files have column headers in the the line. The files must be dynamic. The only common value is that the...
1
by: DThreadgill | last post by:
I have a spreadsheet with about 35 tabs that I need to import into one table in Access. I found this link http://www.thescripts.com/forum/thread650662-import+multiple+tabs.html and changed some...
4
by: franc sutherland | last post by:
Hello, I am using Access 2003. I am having trouble trapping the "can't append all the records in the append query" error message when appending data to a query from a table which is linked to...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.