Hi and HELP!,
I am using Excel and Access 2003. I am trying to create a link to an excel spreadsheet and append the data from a specific sheet called "PEJ". My error is runtime error 3125 "PEJ$" is not a valid name. When I perform these tasks manually it works...any help? Oh, I prefer to link because the spreadsheet data will change quite frequently and I will be performing this function on multiple sheets. - Dim db As Database
-
Dim tdfLinked As TableDef
-
Dim strSearchTable, strTableToFind, TempDate As String
-
Dim myPath As String, myFile As String
-
-
myPath = "c:\documents and settings\NAME\My Documents\NAME\Excel Analytics\ETFs\"
-
myFile = "DTC_032707_1"
-
strTableToFind = "tbl_LINK_" & Me!comboChooseETF
-
TempDate = Format(Date, "mmddyy")
-
Set db = CurrentDb
-
'strSearchTable = "SELECT COUNT(*) FROM MSYSObjects WHERE (((MSYSObjects.Name)='tbl_LINK_PEJ'));"
-
-
If TableExists("" & strTableToFind & "") Then
-
CurrentDb.TableDefs.Delete ("" & strTableToFind & "")
-
End If
-
-
Set tdfLinked = db.CreateTableDef("" & strTableToFind & "")
-
tdfLinked.Connect = _
-
"Excel 5.0;HDR=YES;IMEX=2;DATABASE=" & myPath & myFile & ".xls"
-
Debug.Print myPath & myFile & ".xls"
-
tdfLinked.SourceTableName = "PEJ$"
-
db.TableDefs.Append tdfLinked
-
DoCmd.RunSQL "SELECT " & strTableToFind & ".ETFSymbol, " & strTableToFind & ".CUSIP, " & strTableToFind & ".ETFName, " & strTableToFind & ".TotalQty, " & strTableToFind & ".LastPrice INTO " & Me!comboChooseETF & "_" & TempDate & _
-
" FROM " & strTableToFind
-
-
' DoCmd.RunSQL "DELETE * FROM tbl_LINK_" & Me!comboChooseETF & ";"
-
db.Close
-
Set db = Nothing
-
Set tdfLinked = Nothing
3 1923
I am not to familiar with the link part of excel. I usually just import my records. Try www.utteraccess.com, those guys are more into the module/coding part of different variations of code.
Hi and HELP!,
I am using Excel and Access 2003. I am trying to create a link to an excel spreadsheet and append the data from a specific sheet called "PEJ". My error is runtime error 3125 "PEJ$" is not a valid name. When I perform these tasks manually it works...any help? Oh, I prefer to link because the spreadsheet data will change quite frequently and I will be performing this function on multiple sheets. - Dim db As Database
-
Dim tdfLinked As TableDef
-
Dim strSearchTable, strTableToFind, TempDate As String
-
Dim myPath As String, myFile As String
-
-
myPath = "c:\documents and settings\NAME\My Documents\NAME\Excel Analytics\ETFs\"
-
myFile = "DTC_032707_1"
-
strTableToFind = "tbl_LINK_" & Me!comboChooseETF
-
TempDate = Format(Date, "mmddyy")
-
Set db = CurrentDb
-
'strSearchTable = "SELECT COUNT(*) FROM MSYSObjects WHERE (((MSYSObjects.Name)='tbl_LINK_PEJ'));"
-
-
If TableExists("" & strTableToFind & "") Then
-
CurrentDb.TableDefs.Delete ("" & strTableToFind & "")
-
End If
-
-
Set tdfLinked = db.CreateTableDef("" & strTableToFind & "")
-
tdfLinked.Connect = _
-
"Excel 5.0;HDR=YES;IMEX=2;DATABASE=" & myPath & myFile & ".xls"
-
Debug.Print myPath & myFile & ".xls"
-
tdfLinked.SourceTableName = "PEJ$"
-
db.TableDefs.Append tdfLinked
-
DoCmd.RunSQL "SELECT " & strTableToFind & ".ETFSymbol, " & strTableToFind & ".CUSIP, " & strTableToFind & ".ETFName, " & strTableToFind & ".TotalQty, " & strTableToFind & ".LastPrice INTO " & Me!comboChooseETF & "_" & TempDate & _
-
" FROM " & strTableToFind
-
-
' DoCmd.RunSQL "DELETE * FROM tbl_LINK_" & Me!comboChooseETF & ";"
-
db.Close
-
Set db = Nothing
-
Set tdfLinked = Nothing
Hey, I've never tried any of this and I don't mean to patronise, but I would question the following:
strTableToFind = "tbl_LINK_" & Me!comboChooseETF
Could be that the item in the combo box is incorrect?
tdfLinked.SourceTableName = "PEJ$"
You said it could not find "PEJ$", try removing the "$" and including your file path and file extension: - tdfLinked.SourceTableName = myPath & Me!comboChooseETF.Text & ".xls"
But then again, I'm no expert... If this gets you anywhere though, let me know!
No luck with these suggestions unfortunately...I will be grateful to anyone who can help me with the connecting and linking from Access 2003 to Excel 2003.
Thank you.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: c duden |
last post by:
Excel won't allow documents to be linked to a worksheet in office 2000 when
using C# to create an add-in.
The following code snippets are what was used in the attempts
(there are more...
|
by: Mark T. |
last post by:
Hi,
I've got a simple DB (Office Win XP Professional).
Basically, it's like a check book register - deposit, deduction and running
sum.
I'd like to somehow link it to an Excel spreadsheet that...
|
by: oyk |
last post by:
I hope someone could help me on this. I have linked an excel worksheet to
access but the some data shown in the access table has the #Num errors.
Presumably,
this must be because the data in the...
|
by: jalmar |
last post by:
Hello again:
My second question is:
I am linking an excel spreadsheet into Access, I have it linked and at first had problems getting the information imported into Access-it wasn't importing-I...
|
by: Sajit |
last post by:
I am trying to use an Excel file as a
template for an Access report. I Linked
the Excel file through an unbound frame as
an OLE object with the properties set as
follows:
Source Doc...
|
by: Hendri Adriaens |
last post by:
Hi,
I'm trying to automate the creation of an excel file via COM. I copied my
code below. I read many articles about how to release the COM objects that I
create. The code below runs just fine...
|
by: afr0ninja |
last post by:
Hello!
I'm having an issue with the OutputTo function of Access. I have a few queries that I export to excel (by way of the OutputTo function) This works fine.
I then take an excel sheet...
|
by: karthik28 |
last post by:
I tried linking an excel spreadsheet to an access database. It shows me a window with the data but the header row in missing. However, when I open the excel file, save it without making any changes...
|
by: agarwasa2008 |
last post by:
Hi,
I have a perfect file called "Products.xls" that I link to my MS
Access 2003 database and everytthing looks good in that file.
When I view the same file after linking in my database the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
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: 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: 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: 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: 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...
| |