Solved

VBA Access 2010 Linked Table Issue

Posted on 2011-09-19
4
496 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

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…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now