Solved

VBA Access 2010 Linked Table Issue

Posted on 2011-09-19
4
497 Views
Last Modified: 2012-05-12
Hi,

I have an excel file that update's and select's data from an Access database. The Access database has about 30 tables in it which are all linked tables from other Access databases.

Now the code works fine when using Access 2007 and previous versions. The issue I have with Access 2010 is that the same code doesn't work when selecting data from the linked tables. The error message is the one that say's it cannot find the table.

Now if I go to the database containing the linked tables and open the linked table it opens up fine with all the data showing. I have checked all the locations and again they are all correct. Is this a 2010 issue as the excat same code work for access 2003 & 2007.

Cheers,
0
Comment
Question by:mcs26
  • 2
4 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 36559028
Please post the code.
0
 

Author Comment

by:mcs26
ID: 36559238
Hi Peter,

I do not think its to do with the code but please see it below. The first SQL statement works fine as it's not on a linked table. The second 'cn.Execute strSQL' is where it debugs saying it cannot find the table.

The table name is correct as is the SQL statement. I have copied the statement into the database to test it and it worked fine, could find the table and select the requested data. Like I say this issue has only happend in Access 2010 and not the other versions.

                            'clear prev prices
                            strSQL = "UPDATE _Time_Line_Month " & _
                                        "SET _Time_Line_Month.Open_B = 0, _Time_Line_Month.Open_A = 0, " & _
                                        "_Time_Line_Month.High_B = 0, _Time_Line_Month.High_A = 0, " & _
                                        "_Time_Line_Month.Low_B = 0, _Time_Line_Month.Low_A = 0, " & _
                                        "_Time_Line_Month.Close_B = 0, _Time_Line_Month.Close_A = 0;"
                            
                            cn.Execute strSQL

                            strSQL = "UPDATE [_Time_Line_Month] " & _
                                        "INNER JOIN " & tblName & _
                                        " ON ([_Time_Line_Month].[Time] = [" & tblName & "].[Time]) " & _
                                        "AND ([_Time_Line_Month].[Date] = [" & tblName & "].[Date]) " & _
                                        "SET [_Time_Line_Month].[Open_B] = [" & tblName & "].[Open_B], " & _
                                        "[_Time_Line_Month].[Open_A] = [" & tblName & "].[Open_A], " & _
                                        "[_Time_Line_Month].[High_B] = [" & tblName & "].[High_B], " & _
                                        "[_Time_Line_Month].[High_A] = [" & tblName & "].[High_A], " & _
                                        "[_Time_Line_Month].[Low_B] = [" & tblName & "].[Low_B], " & _
                                        "[_Time_Line_Month].[Low_A] = [" & tblName & "].[Low_A], " & _
                                        "[_Time_Line_Month].[Close_B] = [" & tblName & "].[Close_B], " & _
                                        "[_Time_Line_Month].[Close_A] = [" & tblName & "].[Close_A];"

                            cn.Execute strSQL

Open in new window

0
 
LVL 9

Accepted Solution

by:
borki earned 500 total points
ID: 36559481
Just a thought worth checking: Have you installed Office 2010 SP1?

Can you do a much simpler update query, say just update a single field from the linked table in A2010? Working? Gradually add extra code?

Not sure if this makes a difference, but personally I would try and use a different syntax, eg

UPDATE table SET field list FROM table JOIN other table WHERE condition

Hope that helps
0
 

Author Comment

by:mcs26
ID: 36559787
Hi Borki,

Thanks for the reply. My boss has taken his laptop out with him today. Tomorrow I will try to find out if he has Office 2010 SP1 installed or not. I'll also like you say try a simple query on the linked table from Excel to see if that works. As the the queries above both work when I do them in Access.

Cheers
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Create a EXCEL FIle from Access Procedure 1 19
Allow user to edit an outgoing email 2 25
Access on Mouse move 5 35
DSN-LESS connection to MS Access database 6 30
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question