Avatar of route217
route217Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

Pass through qry error message

Hi Epxerts

I am running the following vba to check my DSN connections....and getting the following error message

3305 (invaild connection string in pass-through qry) in procedure  GetQueryLinks of module bas TableLink


Is ther ea way to change the vba code to replace all old dsn connection with a new one a spoecify if not....how can i trace which one to replace.....


Code:

Public Function GetQueryLinks()
On Error GoTo Err_GetQueryLinks

    Dim qdf As DAO.QueryDef
    Dim strConn As String
    
    'strConn = "'ODBC;Driver={Microsoft ODBC for Oracle};UID=MyUID;PWD=MyPass;SERVER=TheServer;"
        For Each qdf In CurrentDb.QueryDefs
        If qdf.Connect <> "" Then
            qdf.Connect = strConn
            Debug.Print qdf.Connect
        End If
    Next
    
        'Refresh QueryDef
    'CurrentDb.QueryDefs.Refresh
    
Exit_GetQueryLinks:
    Set qdf = Nothing
    Exit Function

Err_GetQueryLinks:
    MsgBox Err.Number & " (" & Err.Description & ") in procedure GetQueryLinks of Module basTableLinks"
    Resume Exit_GetQueryLinks

End Function

Open in new window

Microsoft Access

Avatar of undefined
Last Comment
route217
Avatar of route217
route217
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

ok fixed the above...

gettting a run time error 0

reversed error...
Avatar of Jim Dettman (EE MVE)
In this line:

  'strConn = "'ODBC;Driver={Microsoft ODBC for Oracle};UID=MyUID;PWD=MyPass;SERVER

should be:

strConn = "ODBC;Driver={Microsoft ODBC for Oracle};UID=MyUID;PWD=MyPass;SERVER"

Your other problem is this:

If qdf.Connect <> "" Then


 Your assuming automatically that any external table is an Oracle one.   I would suggest adding a check to look for a specific driver, Server name, DSN or something to decide if you really want to update that tabledefs connect property.

Jim.
Avatar of route217
route217
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Hi Jim

my external table is sql....one
Avatar of route217
route217
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Jim

my main problem is: i cannot run any of the queries.....etc.....how do i over come this

the error message i am getting is

ODBC -- call failed
[Microsoft][ODBC SQL Server Driver][SQL Server]Invaild object name 'apples_extact_tbl_oranges'. (#208)
I think what your problem is, is that one of your existing querydefs already has an invalid SQL statement.

When you hit the error, do:

 ? qdf.Name

 In the debug window (Ctrl/G) and it will give you the name of the querydef that is causing the problem.

 Changing the connect property alone would not normally give you that kind of error message.

Jim.
Avatar of route217
route217
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Hi Jim

sorry for sounding stuiped on my part....i am getting the error message when in queries...and try and run any qry...

so how would i check ?qdf.name.....
<<ODBC -- call failed
[Microsoft][ODBC SQL Server Driver][SQL Server]Invaild object name 'apples_extact_tbl_oranges'. (#208) >>

 I'm getting lost here...

Your question title is "Pass through qry error message", your question mentions "I am running the following vba to check my DSN connections....", which I can't see where your using any, and you code is only working with connect properties of querydefs.

 So let's start over:

1. Create a new linked table to the ''apples_extact_tbl_oranges'' through Access.   Can you open and read the table?

2. Now in the debug window, do:

 ?  CurrentDB().tabledefs("apples_extact_tbl_oranges").Connect

 and hit return.  Then cut and paste the output here.

Then we'll move onto the querydefs if we need to.

Jim.
Avatar of route217
route217
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Hi jim

one more question i know the server name and the database name...can we not just write some vba code to change all existing connect with a newer connect...
See my last comment please.  let's take it one step at a time.

Jim.
Avatar of route217
route217
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Apologies!! Apoogies!!!

1. Create a new linked table to the ''apples_extact_tbl_oranges'' through Access.   Can you open and read the table? - Yes

2. Now in the debug window, do:

 ?  CurrentDB().tabledefs("apples_extact_tbl_oranges").Connect

 and cut and paste here - NAME SHAVE BEEN CHANGED

?CurrentDB().tabledefs("apples_extact_tbl_oranges").ConnectODBC;Description=Banana;DRIVER=SQL Server;SERVER=ABCDr349DT84769.global.hireme.com,34567;UID=1166100;DATABASE=Banana;Trusted_Connection=Yes
ODBC;Description=Banana;DRIVER=SQL Server;SERVER=ABCDr349DT84769.global.hireme.com,34567;UID=1166100;DATABASE=Banana;Trusted_Connection=Yes
ODBC;Description=Banana;DRIVER=SQL Server;SERVER=ABCDr349DT84769.global.hireme.com,34567;UID=1166100;DATABASE=Banana;Trusted_Connection=Yes
ODBC;Description=Banana;DRIVER=SQL Server;SERVER=ABCDr349DT84769.global.hireme.com,34567;UID=1166100;DATABASE=Banana;Trusted_Connection=Yes
ODBC;Description=Banana;DRIVER=SQL Server;SERVER=ABCDr349DT84769.global.hireme.com,34567;UID=1166100;DATABASE=Banana;Trusted_Connection=Yes
ODBC;Description=Banana;DRIVER=SQL Server;SERVER=ABCDr349DT84769.global.hireme.com,34567;UID=1166100;DATABASE=Banana;Trusted_Connection=Yes
ODBC;Description=Banana;DRIVER=SQL Server;SERVER=ABCDr349DT84769.global.hireme.com,34567;UID=1166100;DATABASE=Banana;Trusted_Connection=Yes



Then we'll move onto the querydefs if we need to.
Avatar of route217
route217
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

sorry for posting the same message 4 time...
OK, so now we know what the connect string should look like:

ODBC;Description=Banana;DRIVER=SQL Server;SERVER=ABCDr349DT84769.global.hireme.com,34567;UID=1166100;DATABASE=Banana;Trusted_Connection=Yes

and there is no DSN involved.  This is a straight connection string to SQL specifying the server, user, etc.

Now what is it that you want to accomplish exactly?

1. Change the existing table linking?
2. Change all the query connects?

etc.

and what is it that we want to change?   Server?  User?  etc.

Jim.
Avatar of route217
route217
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Hi Jim

Now what is it that you want to accomplish exactly? - connect the tables so all the qry's work

1. Change the existing table linking? - not sure on this one
2. Change all the query connects? - yes..

etc.

and what is it that we want to change?   Server?  User?  etc

Basically in a nutshell i want the linked tables to connect to the qry and produce an output...

as you have point out berfore  - one step at a time - like this approach

not sure what i have done work.....
Avatar of route217
route217
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

point 1. above message...change the link table linking..exiting...would this work???
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of route217
route217
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Thanks Jim

for the excellent feedback...what I had above can from another question so if its not to rude what's the complete vba code..
<<for the excellent feedback...what I had above can from another question so if its not to rude what's the complete vba code.. >>

 I was little vague because I'm still not quite sure exactly what it is your trying to change in the connect string.

 You have the outline of the routine already.   You just need to add a few lines of code to:

a. make sure you do want to change the current querydef.

b. change it, either by replacing the string entirely or replacing just a portion of it (like the server name).

  I can't get any more specific unless you tell me exactly what it is your doing.

  Your like 90% of the way there....

Jim.
Avatar of route217
route217
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

jim..

let me glue the vba code together. ..based on ur feedback. .
Avatar of route217
route217
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

hi jim

sorry for asking having a nightmare on this question can u assist???
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo