Solved

VBA Access 2010 Linked Table Issue

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Access printing shortcut in Ms Access 10 36
Combobox issue 4 27
Syntax using Declare 3 16
Access Delimiter for check box filter 3 14
This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

743 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

10 Experts available now in Live!

Get 1:1 Help Now