I'm using the following code to import data from Excel to Access: - Public Sub ImportMatrix()
-
Dim db As DAO.Database
-
On Error GoTo Error_Handler
-
-
Set db = CurrentDb
-
-
DoCmd.Hourglass True
-
-
db.TableDefs.Refresh
-
DoCmd.TransferSpreadsheet _
-
TransferType:=acImport, _
-
SpreadsheetType:=acSpreadsheetTypeExcel9, _
-
TableName:="tblMatrix", _
-
FileName:="\\ftcbank1\docs\sschrock\My Documents\Database Stuff\FTC Morgage Rate Database\Mortgage Matrix.xls", _
-
HasFieldNames:=False, _
-
Range:="MatrixTable"
-
db.TableDefs.Refresh
-
-
-
Exit_Procedure:
-
Set db = Nothing
-
DoCmd.Hourglass False
-
-
Exit Sub
-
-
Error_Handler:
-
'Call ErrorMessage(Err.Number, Err.Description, "modImport: ImportMatrix")
-
'TSCs_ReportUnexpectedError "ImportMatrix", "modImport", "Custom info"
-
Resume Exit_Procedure
-
Resume
-
-
-
End Sub
-
I have a named range within the excel file titled MatrixTable and from looking on the MSDN website, I should be able to use the name of the range. I don't get any errors, but no data gets transferred. tblMatrix is a pre-existing table. I'm not sure what to try at this point.
5 1887
I have used the following bit of code without incident: - DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tbl_CustomCommentImportReplies", strImportFile, , "Comments!A:L"
This works to import columns A through L on the sheet named Comments.
I remember that I often spend a fair amount of time tinkering with Excel exports to get them to work just as I want. Have you tried adding a exclamation before Matrixtable, so that:
I am really just guessing here.
I have had so many issues using TheSmileyCoder code here above, because my field types (ie text or number etc) were different in Excel and Access for the same fields. If they are the same, then it should import in no time.
Most excel sheets I issue for use as remove data entry, I lock down before issue, so that users can only type in certain fields, and do certain actions. This greatly limits the number of things that can go wrong, although it is not always an option.
I also usually import to a temp table first, to weed out any import errors before appending to the live data.
Are you sure the import range is typed correctly? What happens if you deliberately type a non-existing importrange such as DonaldDuck? Does it give an error message then?
I tried moving it to my computer so that there is no network problems and I put in the actual range so I now have - DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tblMatrix", _
-
"C:\Databases\Mortgage Matrix.xlsm", False, "NewSheet!A1:E126"
I still get no error message (I did try DonaldDuck as the range and didn't get an error message that time either), but still, no records are imported. I made sure that all of the data types in the excel file are numbers and that they match the access table.
I figured it out. Very dumb mistake. I had my table missing a field that was in the excel sheet. I ended up having the excel sheet have field names and I was able to use the named range just like I had in my OP. Thanks Smiley for your help.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: bburton |
last post by:
I'm using a form in Access which was used as a bug tracker. The users
could update the record with an attachment. (The data type of the
field that is used for attachments is the OLE Object)
I...
|
by: Reggae |
last post by:
Hello,
I am looking for the most efficient way to programmatically batch
import excel files into MS Access. The excel files are not lined up in
a row and currently I am going to each file so I...
|
by: john |
last post by:
I have 400 different Excel-spreadsheetfiles, same structure, all with only
one record in it, and all residing in the same folder. Every now and then
new Excel files are being added. In my Access...
|
by: menmysql |
last post by:
i am not bale to solve this problem since two weeks
i am trying to access records from mysql database using jsp. inside this jsp program i wrote all my JDBC code. it is working very nicely and...
|
by: nehashri |
last post by:
hello
i have my data stored in different Ms Excell sheets. now I am planning to make a database of the data i have. but i m confused whether to use Postgresql or mySQL for the same. i had plans to...
|
by: Dave Williams |
last post by:
Im not a techie but run a small business in UK. We take instructions from clients from emails hard copy, spreadsheets etc and put them on excel templates then import to Access. A client wants us to...
|
by: satenova |
last post by:
Hello Friends,
I am newbie when it comes to vb.net and i need to import excel sheet into access db using vb.net application. Here is the code i use for now to upload excel sheet and it works...
|
by: jollyroger |
last post by:
I have searched the web forums, and can't seem to find an answer to this particular problem I have.
In an excel sheet, cells in one column have formatted text in the "wrapped" cells. For many of...
|
by: dowlingm815 |
last post by:
I am importing an Excel 97-2003 file into Access 2003. The number of rows within the Excel file is 101,9992. When completed the Access import, only 65,535 are import.
Is Access limited, if so,...
|
by: prashantdixit |
last post by:
Hi,
I have beent trying importing Excel data with one column containing PDF/JPEG file name to access 2007.
I have a Excel file with few columns
One of the columns named as "Reference". The...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
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$) {
}
...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
| | |