?
Solved

VBA Access 2010 Linked Table Issue

Posted on 2011-09-19
4
Medium Priority
?
509 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

800 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