PC Review


Reply
Thread Tools Rate Thread

Import Excel sheets to Access

 
 
Rod Manson
Guest
Posts: n/a
 
      18th Jun 2008
I have used the following code to import excel data into Access database
tables. It works but won't bring in any more than the first 270 records. Can
anyone explain why please and let me know how to resolve the problem?

Thanks.

Public Sub TestCode1()

Dim strPrompt As String, strTitle As String, strDefaultExcelSheet As String,
strExcelSheetName As String, strTable As String

DoCmd.SetWarnings False

strPrompt = "Enter the full file Path and name of the
Spreadsheet you want to import.."
strTitle = "Spreadsheet Location and Name"
strDefaultExcelSheet = "J:\CADPHH\DC3160\Modelling\Traffic
Data\O&D CLEANED data\Survey1.xls"
strExcelSheetName = InputBox(strPrompt, strTitle,
strDefaultExcelSheet)
strTable = "ImportTest"

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8,
strTable, strExcelSheetName, True

DoCmd.SetWarnings True
DoCmd.OpenTable strTable

End Sub
 
Reply With Quote
 
 
 
 
Klatuu
Guest
Posts: n/a
 
      18th Jun 2008
My guess is there is a blank row at row 272 in your spreadsheet.
--
Dave Hargis, Microsoft Access MVP


"Rod Manson" wrote:

> I have used the following code to import excel data into Access database
> tables. It works but won't bring in any more than the first 270 records. Can
> anyone explain why please and let me know how to resolve the problem?
>
> Thanks.
>
> Public Sub TestCode1()
>
> Dim strPrompt As String, strTitle As String, strDefaultExcelSheet As String,
> strExcelSheetName As String, strTable As String
>
> DoCmd.SetWarnings False
>
> strPrompt = "Enter the full file Path and name of the
> Spreadsheet you want to import.."
> strTitle = "Spreadsheet Location and Name"
> strDefaultExcelSheet = "J:\CADPHH\DC3160\Modelling\Traffic
> Data\O&D CLEANED data\Survey1.xls"
> strExcelSheetName = InputBox(strPrompt, strTitle,
> strDefaultExcelSheet)
> strTable = "ImportTest"
>
> DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8,
> strTable, strExcelSheetName, True
>
> DoCmd.SetWarnings True
> DoCmd.OpenTable strTable
>
> End Sub

 
Reply With Quote
 
 
 
 
Rod Manson
Guest
Posts: n/a
 
      19th Jun 2008
Thanks Dave. I've sorted it. There were multiple worksheets and it was not
loading the correct one as I missed the 'range' variable from the end of the
docmd command!

"Klatuu" wrote:

> My guess is there is a blank row at row 272 in your spreadsheet.
> --
> Dave Hargis, Microsoft Access MVP
>
>
> "Rod Manson" wrote:
>
> > I have used the following code to import excel data into Access database
> > tables. It works but won't bring in any more than the first 270 records. Can
> > anyone explain why please and let me know how to resolve the problem?
> >
> > Thanks.
> >
> > Public Sub TestCode1()
> >
> > Dim strPrompt As String, strTitle As String, strDefaultExcelSheet As String,
> > strExcelSheetName As String, strTable As String
> >
> > DoCmd.SetWarnings False
> >
> > strPrompt = "Enter the full file Path and name of the
> > Spreadsheet you want to import.."
> > strTitle = "Spreadsheet Location and Name"
> > strDefaultExcelSheet = "J:\CADPHH\DC3160\Modelling\Traffic
> > Data\O&D CLEANED data\Survey1.xls"
> > strExcelSheetName = InputBox(strPrompt, strTitle,
> > strDefaultExcelSheet)
> > strTable = "ImportTest"
> >
> > DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8,
> > strTable, strExcelSheetName, True
> >
> > DoCmd.SetWarnings True
> > DoCmd.OpenTable strTable
> >
> > End Sub

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Print sheets by "All Sheets in workbook, EXCEPT for specific named sheets". Possible? Corey Microsoft Excel Programming 2 11th Dec 2006 02:35 AM
Import Excel sheets into Access Neo Microsoft Access Form Coding 1 17th Jan 2006 06:42 PM
how to import multiple excel sheets into access =?Utf-8?B?QW1pdGFiaCBTYXJhZg==?= Microsoft Access External Data 2 27th Sep 2004 09:35 PM
Import Multiple Excel Sheets into Access 2000 Stever Microsoft Access External Data 1 23rd Oct 2003 12:55 AM
Excel Data in many Sheets - Import to Access Andre Microsoft Access External Data 2 30th Jul 2003 05:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:41 PM.