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

Changing Path for table linked to spreadsheet

Hi everyone,

I am using Access 2003. I have a database with a table in it which is
linked to an excel spreadsheet. When I install the database on
someone else's system, the pathname to the excel file is different.
Howwever, as it is in runtime on their system, I can't update the link
using the Linked Table Manager.

Is there a way of using a public constant to store a path which can be
altered in advance and then combined with a startup module to change
the link path?

I have tried using the rRefreshLink function, but it gives me error
3343, Unrecognised database format. I think this function is aimed at
re-freshing links to BE mdb files and doesn't work with tables linked
to excel spreadsheets.

Lots of thanks in advance,

Franc.
Oct 22 '08 #1
7 8398
On Tue, 21 Oct 2008 17:28:58 -0700 (PDT), franc sutherland
<fr**************@googlemail.comwrote:

You'd want to read up on RefreshLink a bit more. This function in
combination with the Connect property is how you can change links at
runtime. You can indeed use a constant for the location, or use a
File/Open dialog.

Perhaps this article will help:
http://www.mvps.org/access/tables/tbl0012.htm
And bookmark that site!

-Tom.
Microsoft Access MVP

>Hi everyone,

I am using Access 2003. I have a database with a table in it which is
linked to an excel spreadsheet. When I install the database on
someone else's system, the pathname to the excel file is different.
Howwever, as it is in runtime on their system, I can't update the link
using the Linked Table Manager.

Is there a way of using a public constant to store a path which can be
altered in advance and then combined with a startup module to change
the link path?

I have tried using the rRefreshLink function, but it gives me error
3343, Unrecognised database format. I think this function is aimed at
re-freshing links to BE mdb files and doesn't work with tables linked
to excel spreadsheets.

Lots of thanks in advance,

Franc.
Oct 22 '08 #2
On Oct 21, 7:28*pm, franc sutherland <franc.sutherl...@googlemail.com>
wrote:
Hi everyone,

I am using Access 2003. *I have a database with a table in it which is
linked to an excel spreadsheet. *When I install the database on
someone else's system, the pathname to the excel file is different.
Howwever, as it is in runtime on their system, I can't update the link
using the Linked Table Manager.

Is there a way of using a public constant to store a path which can be
altered in advance and then combined with a startup module to change
the link path?

I have tried using the rRefreshLink function, but it gives me error
3343, Unrecognised database format. *I think this function is aimed at
re-freshing links to BE mdb files and doesn't work with tables linked
to excel spreadsheets.

Lots of thanks in advance,

Franc.
Franc,

I have an application where I point to multiple spreadsheets based on
standard rules.

In this case, each plant has a folder, and each year of the survey has
its own folder, and each file has the same name. And, I use a generic
table named xlimportsurvey as my link.

So, they choose cmbSurvey and cmbPlantChooser, and I build the file
location as strFileLocation. You, of corse, could just set
strFileLocation as the generic variable.
-----------------------------------------------------------------------------------------------------------
Dim strFileLocation As String

If Not IsNull(Me.cmbSurvey) And Not IsNull(Me.cmbPlantChooser) Then

strFileLocation = "\\srvr\share\Projects\Survey\" & Me.cmbSurvey &
_
"\" & Me.cmbPlantChooser & "\sheet_1.xls"

' This IfThen deletes the old table if it exists because if you don't,
then it just creates a new link with a "1" appended to the end.
If DCount("*", "MsysObjects", "[Name]= 'xlimportsurvey'") Then
DoCmd.DeleteObject acTable, "xlimportsurvey"
End If

'This line reestablishes the link to the new location.
DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel8,
"xlimportsurvey", _
strFileLocation, False, "A3:AG1000"

End If

Me.RecordSource = "qrysurvey" 'This query uses xlimportsurvey as one
of its tables. So, resetting the recordsource is needed, not just a
requery.

'These requeries are for listboxes which need to be repopulated. Not
really relevant to your issue.
Me.Combo46.Requery
Me.Combo48.Requery
Me.List52.Requery

-------------------------------------------------------------------------
Yah, I was lazy and didn't rename Combo46, Combo48, and List52 during
development... :) Crazy the stuff you find when you go back and look
at your old code.

All thanks to whichever Access Gods had the transferspreadsheet method
documented on their websites. I found 3 or 4 references to it once I
hit on the right google search.

Jon
Oct 22 '08 #3
On Oct 21, 8:28*pm, franc sutherland <franc.sutherl...@googlemail.com>
wrote:
Hi everyone,

I am using Access 2003. *I have a database with a table in it which is
linked to an excel spreadsheet. *When I install the database on
someone else's system, the pathname to the excel file is different.
Howwever, as it is in runtime on their system, I can't update the link
using the Linked Table Manager.

Is there a way of using a public constant to store a path which can be
altered in advance and then combined with a startup module to change
the link path?

I have tried using the rRefreshLink function, but it gives me error
3343, Unrecognised database format. *I think this function is aimed at
re-freshing links to BE mdb files and doesn't work with tables linked
to excel spreadsheets.

Lots of thanks in advance,

Franc.
Did you use UNC to link your tables/spreadsheets ???
bobh.
Oct 22 '08 #4
On Oct 22, 2:40*pm, Tom van Stiphout <tom7744.no.s...@cox.netwrote:
On Tue, 21 Oct 2008 17:28:58 -0700 (PDT), franc sutherland

<franc.sutherl...@googlemail.comwrote:

You'd want to read up on RefreshLink a bit more. This function in
combination with the Connect property is how you can change links at
runtime. You can indeed use a constant for the location, or use a
File/Open dialog.

Perhaps this article will help:http://www.mvps.org/access/tables/tbl0012.htm
And bookmark that site!

-Tom.
Microsoft Access MVP
Hi everyone,
I am using Access 2003. *I have a database with a table in it which is
linked to an excel spreadsheet. *When I install the database on
someone else's system, the pathname to the excel file is different.
Howwever, as it is in runtime on their system, I can't update the link
using the Linked Table Manager.
Is there a way of using a public constant to store a path which can be
altered in advance and then combined with a startup module to change
the link path?
I have tried using the rRefreshLink function, but it gives me error
3343, Unrecognised database format. *I think this function is aimed at
re-freshing links to BE mdb files and doesn't work with tables linked
to excel spreadsheets.
Lots of thanks in advance,
Franc.
Hi Tom,

Thanks for the link. Very useful stuff indeed.

It's bookmarked!

All the best,

Franc.
Oct 23 '08 #5
On Oct 22, 5:56*pm, jonceramic <joncera...@gmail.comwrote:
On Oct 21, 7:28*pm, franc sutherland <franc.sutherl...@googlemail.com>
wrote:
Hi everyone,
I am using Access 2003. *I have a database with a table in it which is
linked to an excel spreadsheet. *When I install the database on
someone else's system, the pathname to the excel file is different.
Howwever, as it is in runtime on their system, I can't update the link
using the Linked Table Manager.
Is there a way of using a public constant to store a path which can be
altered in advance and then combined with a startup module to change
the link path?
I have tried using the rRefreshLink function, but it gives me error
3343, Unrecognised database format. *I think this function is aimed at
re-freshing links to BE mdb files and doesn't work with tables linked
to excel spreadsheets.
Lots of thanks in advance,
Franc.

Franc,

I have an application where I point to multiple spreadsheets based on
standard rules.

In this case, each plant has a folder, and each year of the survey has
its own folder, and each file has the same name. *And, I use a generic
table named xlimportsurvey as my link.

So, they choose cmbSurvey and cmbPlantChooser, and I build the file
location as strFileLocation. *You, of corse, could just set
strFileLocation as the generic variable.
-----------------------------------------------------------------------------------------------------------
Dim strFileLocation As String

If Not IsNull(Me.cmbSurvey) And Not IsNull(Me.cmbPlantChooser) Then

* * strFileLocation = "\\srvr\share\Projects\Survey\" & Me.cmbSurvey &
_
* * * * * * * * * * * * "\" & Me.cmbPlantChooser & "\sheet_1.xls"

' This IfThen deletes the old table if it exists because if you don't,
then it just creates a new link with a "1" appended to the end.
* * If DCount("*", "MsysObjects", "[Name]= 'xlimportsurvey'") Then
* * * * DoCmd.DeleteObject acTable, "xlimportsurvey"
* * End If

'This line reestablishes the link to the new location.
* * DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel8,
"xlimportsurvey", _
* * * * * * * * * * * * * * * * strFileLocation, False, "A3:AG1000"

End If

Me.RecordSource = "qrysurvey" *'This query uses xlimportsurvey as one
of its tables. *So, resetting the recordsource is needed, not just a
requery.

'These requeries are for listboxes which need to be repopulated. *Not
really relevant to your issue.
* * Me.Combo46.Requery
* * Me.Combo48.Requery
* * Me.List52.Requery

-------------------------------------------------------------------------
Yah, I was lazy and didn't rename Combo46, Combo48, and List52 during
development... *:) *Crazy the stuff you find when you go back and look
at your old code.

All thanks to whichever Access Gods had the transferspreadsheet method
documented on their websites. *I found 3 or 4 references to it once I
hit on the right google search.

Jon
Hi Jon,

Thanks for that. It is a very different approach and it is always
good to learn about all the different ways that are possible in
Access. I was wondering in your scenario, with the two combo boxes
which build the file pathname string. Does the combo box look up the
file directory and list the options, or do you keep a table with the
names?

All the best,

Franc,
Oct 23 '08 #6
On Oct 22, 5:59*pm, bobh <vulca...@yahoo.comwrote:
On Oct 21, 8:28*pm, franc sutherland <franc.sutherl...@googlemail.com>
wrote:
Hi everyone,
I am using Access 2003. *I have a database with a table in it which is
linked to an excel spreadsheet. *When I install the database on
someone else's system, the pathname to the excel file is different.
Howwever, as it is in runtime on their system, I can't update the link
using the Linked Table Manager.
Is there a way of using a public constant to store a path which can be
altered in advance and then combined with a startup module to change
the link path?
I have tried using the rRefreshLink function, but it gives me error
3343, Unrecognised database format. *I think this function is aimed at
re-freshing links to BE mdb files and doesn't work with tables linked
to excel spreadsheets.
Lots of thanks in advance,
Franc.

Did you use *UNC *to link your tables/spreadsheets ???
bobh.
Hi Bob,

Yes, I used \\server\folder\subfolder\ etc....

All the best,

Franc.
Oct 23 '08 #7
On Oct 23, 12:29*pm, franc sutherland
<franc.sutherl...@googlemail.comwrote:
On Oct 22, 5:56*pm, jonceramic <joncera...@gmail.comwrote:


On Oct 21, 7:28*pm, franc sutherland <franc.sutherl...@googlemail.com>
wrote:
Hi everyone,
I am using Access 2003. *I have a database with a table in it whichis
linked to an excel spreadsheet. *When I install the database on
someone else's system, the pathname to the excel file is different.
Howwever, as it is in runtime on their system, I can't update the link
using the Linked Table Manager.
Is there a way of using a public constant to store a path which can be
altered in advance and then combined with a startup module to change
the link path?
I have tried using the rRefreshLink function, but it gives me error
3343, Unrecognised database format. *I think this function is aimedat
re-freshing links to BE mdb files and doesn't work with tables linked
to excel spreadsheets.
Lots of thanks in advance,
Franc.
Franc,
I have an application where I point to multiple spreadsheets based on
standard rules.
In this case, each plant has a folder, and each year of the survey has
its own folder, and each file has the same name. *And, I use a generic
table named xlimportsurvey as my link.
So, they choose cmbSurvey and cmbPlantChooser, and I build the file
location as strFileLocation. *You, of corse, could just set
strFileLocation as the generic variable.
---------------------------------------------------------------------------*--------------------------------
Dim strFileLocation As String
If Not IsNull(Me.cmbSurvey) And Not IsNull(Me.cmbPlantChooser) Then
* * strFileLocation = "\\srvr\share\Projects\Survey\" & Me.cmbSurvey &
_
* * * * * * * * * * * * "\" & Me.cmbPlantChooser & "\sheet_1.xls"
' This IfThen deletes the old table if it exists because if you don't,
then it just creates a new link with a "1" appended to the end.
* * If DCount("*", "MsysObjects", "[Name]= 'xlimportsurvey'") Then
* * * * DoCmd.DeleteObject acTable, "xlimportsurvey"
* * End If
'This line reestablishes the link to the new location.
* * DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel8,
"xlimportsurvey", _
* * * * * * * * * * * * * * * * strFileLocation, False, "A3:AG1000"
End If
Me.RecordSource = "qrysurvey" *'This query uses xlimportsurvey as one
of its tables. *So, resetting the recordsource is needed, not just a
requery.
'These requeries are for listboxes which need to be repopulated. *Not
really relevant to your issue.
* * Me.Combo46.Requery
* * Me.Combo48.Requery
* * Me.List52.Requery
-------------------------------------------------------------------------
Yah, I was lazy and didn't rename Combo46, Combo48, and List52 during
development... *:) *Crazy the stuff you find when you go back and look
at your old code.
All thanks to whichever Access Gods had the transferspreadsheet method
documented on their websites. *I found 3 or 4 references to it once I
hit on the right google search.
Jon

Hi Jon,

Thanks for that. *It is a very different approach and it is always
good to learn about all the different ways that are possible in
Access. *I was wondering in your scenario, with the two combo boxes
which build the file pathname string. *Does the combo box look up the
file directory and list the options, or do you keep a table with the
names?

All the best,

Franc,- Hide quoted text -

- Show quoted text -
Well, in my case, I'm downloading a flat excel file from a commerical
survey website. And, I have to do this manually. So, since I have
only 5 folder and I'm the one doing it, I just made it happen manually
by seeding my own lists and using names I create. I never looked into
automating that side of it.

BTW, I realized my raw code is confusing. If I take out the code to
the essence, you're left with this...

strFileLocation = "\\server\folder\" & strMycustomfolder &
"\subfolder\" & strMycustomfilename
strTableName = "mytablename"

If DCount("*", "MsysObjects", "[Name]= '"& strTableName & "'")
Then
DoCmd.DeleteObject acTable, strTableName
End If

DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel8,
strTableName _
strFileLocation, False, "A3:AG1000"

Me.RecordSource = strTableName

(NOTE: I use A3:AG1000 as my source because that's where my data
happens to be. You'll obviously pick something different. I think
general Excel conventions work here if you have multiple tabs.)

Jon
Oct 23 '08 #8

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

Similar topics

3
by: James Bird | last post by:
Hello In order to perform a hetrogeneous join (I think that's what they're called) between MySQL and another database, I've created an Access database containing linked tables from each...
3
by: John Lewis | last post by:
I hope someone can help with this. I have a website using Access and ASP developed on my own PC (using PWS) and hosted on a commercial site. I decided that splitting the dbase up would be a...
3
by: johnsnellx | last post by:
Well, I sure could use some advice (& sympathy). In my Access program I have a small table (200 entries) linked to a main table of over 35,000 entries. While trying to enter a small amount of data...
2
by: m23 | last post by:
Hi, I have an access database unfortunately still running under access 97. This contains a number of linked tables to another access 97 database. I was wandering if there is a way to edit...
0
by: reynard.michel | last post by:
Hi, In a sql server database I've a table with a float field. I also have a view on this table. The table and the view are linked in an access database. If I look to theyre properties I get a...
2
by: jalmar | last post by:
Hello....I'm back again with the same question. I still haven't been able to figure out why my query isn't working. I am linking a table to an Excel spreadsheet, that part is fine, it is even...
0
by: ceejee | last post by:
hello there! especially to those experts here in this forum. glad to be here. this is my first post here and sorry if its a problem. later i will try to answer also those questions where i have...
2
by: franc sutherland | last post by:
Hello everyone, I am using Access 2003. In my database there is a table which is linked to an excel spreadsheet. When I move the mdb file to someone else's computer the spreadsheet will be in...
10
by: laughlin | last post by:
Hello, I was wondering if it were possible in Access to make a linked spreadsheet's path be based upon the filename of the Access database that it is in. For instance, if the database is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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?
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
jinu1996
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...
0
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 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.