Currently i use the TransferSpreadsheet acImport method, to import an Excel file called "Athletedata.xls", into a table called "Cyclist".
I would now like to select the file from any directory, instead of having to import it from a specific directory only.
I use this code currently to import the Athletedata.xls file. Please assist - DoCmd.SetWarnings False
-
DoCmd.TransferSpreadsheet acImport, 10, "Cyclist", "c:\RTBU\AthleteData.xls", True, ""
-
You don't actually use the result returned (strPath) in your TransferSpreadsheet line (#10).
It should look more like : - Dim strPath As String
-
-
With Me
-
strPath = Left(.lblFile.Caption, InStrRev(.lblFile.Caption, "\"))
-
strPath = FSBrowse(strStart:=strPath, _
-
lngType:=msoFileDialogFilePicker, _
-
strPattern:="MS Excel,*.xls")
-
If strPath > "" Then
-
.lblFile.Caption = strPath
-
Call DoCmd.SetWarnings(False)
-
Call DoCmd.TransferSpreadsheet(acImport, _
-
acSpreadsheetTypeExcel11, _
-
"Cyclist", _
-
strPath, _
-
True)
-
Call DoCmd.SetWarnings(True)
-
End If
-
End With
6 2006
When i use your code and module, it opens up at i can select the Excel file using this code, but i do not get it to import data. Where do i go wrong? - Dim strPath As String
-
-
With Me
-
strPath = Left(.lblFile.Caption, InStrRev(.lblFile.Caption, "\"))
-
strPath = FSBrowse(strStart:=strPath, _
-
lngType:=msoFileDialogFilePicker, _
-
strPattern:="MS Excel,*.xls")
-
If strPath > "" Then .lblFile.Caption = strPath
-
DoCmd.SetWarnings False
-
DoCmd.TransferSpreadsheet acImport, 10, "Cyclist", "", True, ""
-
-
End With
NeoPa 32,556
Expert Mod 16PB
You don't actually use the result returned (strPath) in your TransferSpreadsheet line (#10).
It should look more like : - Dim strPath As String
-
-
With Me
-
strPath = Left(.lblFile.Caption, InStrRev(.lblFile.Caption, "\"))
-
strPath = FSBrowse(strStart:=strPath, _
-
lngType:=msoFileDialogFilePicker, _
-
strPattern:="MS Excel,*.xls")
-
If strPath > "" Then
-
.lblFile.Caption = strPath
-
Call DoCmd.SetWarnings(False)
-
Call DoCmd.TransferSpreadsheet(acImport, _
-
acSpreadsheetTypeExcel11, _
-
"Cyclist", _
-
strPath, _
-
True)
-
Call DoCmd.SetWarnings(True)
-
End If
-
End With
Thx Neopa for the trouble. My data would not import until i changed acSpreadsheetTypeExcel11, to acSpreadsheetTypeExcel9. It is Now working fine
Neopa. I decided to create a standard template in Excel with fixed titles. It works great except for one problem - It creates lots of empty rows. I sorted that with a delete query to get rids of blanks, when viewing the data. Duplicates entries are not an issue because one of my fields prevent duplicates, and the "setwarnings" function keeps the system quiet.
Thx again for the excellent service !!
NeoPa 32,556
Expert Mod 16PB NeelsFer:
My data would not import until i changed acSpreadsheetTypeExcel11, to acSpreadsheetTypeExcel9.
My bad Neels. That was a guess as I'm working on 2003 myself and only have up to acSpreadsheetTypeExcel9.
As for your Excel template, try opening it, selecting all rows from where the worksheet should end (I'm guessing row #2) to the bottom and deleting them (Using right-click / Delete rather than the Del key - which simply clears their contents). Once this has been saved it should work better as a template for you.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Little PussyCat |
last post by:
Hello,
I nee to write something that will transfer excel data into an SQL Server
table.
I have for another database application I wrote have it importing Excel
spreadsheet data using cell by...
|
by: zino |
last post by:
I have a file that is created in Excel and saved as an htm file.
(if I open the file through Excel it open as Excel file, if I click on the
file name it open in internet explorer).
I need to...
|
by: mail2atulmehta |
last post by:
Hi,
I do not know if this is right place for this, but i need some help. I
have a text file, whose values are seprated by a delimiter. I want to
open this file in excel, ( not import it) . I have...
|
by: WODJ |
last post by:
Folks,
I hope someone out there can please help me, not much hair left with this one.
I'm importing excel data into a SQL server database using an Oledb connection in C#. The problemm is that...
|
by: Vardhini Gold |
last post by:
Hi,
I am Vardhini. The project that I am working for is a web based application.
I use ASP.2.0/ VB.NET (Visual studio 2005).
Kindly help me in importing excel contents to SQL Database using...
|
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...
|
by: christiekp |
last post by:
I am able to import a file from excel to access manually, using the top row as my headings, successfully. however, when using the TransferSpreadsheet command in a macro, importing, excel 5-7, has...
|
by: jld730 |
last post by:
Greetings!
I am still new to Python, sorry! I have been searching through many posts on this subject and have attempted to TRY, but I feel really lost. So, any detailed guidance would be oh-so...
|
by: pakerly |
last post by:
How would i do this, convert a test file to excel?
Lets say my text file has fields like this:
NUMBER NAME ADDRESS PHONE
11002 Test1 ...
|
by: chethan g |
last post by:
Hi,
I need to select the whole Excel sheet in Range object and then need to apply "alignment" and "autofit column width".
As I have many merged cells, when I attempt to autofit the column width I...
|
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
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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: 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: 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...
|
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...
| | |