Relinking Queries through Code

Meltdown

Registered User.
Local time
Today, 12:31
Joined
Feb 25, 2002
Messages
472
Relinking Pass Through Queries through Code

Hi all,

I have a lot of pass-through queries in a database, the connection string is stored in the properties of the query, does anyone have any code to relink these queries when the database opens?

I think querydefs might do it but I haven't come accross any examples so far.

Thanks
Melt
 
Last edited:
OK I got this coded myself, not to difficult after all.

PHP:
Dim qdf As dao.QueryDef
    Dim dbs As dao.Database

Set dbs = CurrentDb

' create connection string
Dim strConnect As String
        strConnect = "ODBC;DRIVER={SQL Native Client}" _
                & ";SERVER=server_name" _
                & ";DATABASE=database_name" _
                & ";UID=my_user" _
                & ";Trusted_Connection=Yes" & ";"

For Each qdf In dbs.QueryDefs

    If qdf.Type = dbQSQLPassThrough Then
        qdf.Connect = strConnect
    End If

Next qdf

dbs.Close
 
Last edited:

Users who are viewing this thread

Back
Top Bottom