[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 515
  • Last Modified:

VBA Access 2010 Linked Table Issue

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
mcs26
Asked:
mcs26
  • 2
1 Solution
 
peter57rCommented:
Please post the code.
0
 
mcs26Author Commented:
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
 
borkiCommented:
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
 
mcs26Author Commented:
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now