Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Connection String in pass through queries

Author  Topic 

KnooKie
Aged Yak Warrior

623 Posts

Posted - 2002-03-13 : 09:49:03
I have the following code that happily populates a combo box using a pass through query. The problem is i have to place the ODBC connection string (ODBC;DSN=sql_tos_dev_uk_2;UID=myUID;PWD=myPSWD;)in the ODBC connect str property of every pass through query.

So my question....is there a way to assign this connection string to this property using VBA which will save me having to specify it in every pass through query ?? i.e. i can assign the connection string to a variable and set the property within my VBA code.

Also (but not so important) is there a way of doing pass through queries using a OLEDB connection string and so leaving out the UID and PSWD parameters altogether ?

I am using Access97 connecting to SQL7.

many thanks
Paul

The code......

'Populate the drop-down Plc list combo
Dim qdfPlcList As QueryDef
Dim strSQL As String

Set db = CurrentDb

Set qdfPlcList = db.QueryDefs("qry_QairePlcList") 'a passthrough query
strSQL = "EXECUTE usp_QairePlcList_sel " & gsUID
qdfPlcList.sql = strSQL

Me.cbo_PlcList.RowSource = "qry_QairePlcList"
Set qdfPlcList = Nothing

Love like you've never been hurt,
Dance like no one is watching,
Sing like no ones listening.

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2002-04-08 : 04:18:27
Sorry - I may not be understanding your question correctly, but can't you set the connection property for the querydef as follows:

'Populate the drop-down Plc list combo
Dim qdfPlcList As QueryDef
Dim strSQL As String

Set db = CurrentDb

Set qdfPlcList = db.QueryDefs("qry_QairePlcList") 'a passthrough query
strSQL = "EXECUTE usp_QairePlcList_sel " & gsUID
qdfPlcList.sql = strSQL
qdfPlcList.Connection = MyDB.connection

Me.cbo_PlcList.RowSource = "qry_QairePlcList"
Set qdfPlcList = Nothing



--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page
   

- Advertisement -