Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass Through Query and updating on the fly

Status
Not open for further replies.

scottsanpedro

Programmer
Apr 26, 2002
97
0
0
GB
Hi,
I need to be able to change the properties on a pass through query, in fact a load of them.
As you can see, I have the code and all pass through 's get updated correctly.
Code:
strConnect = "ODBC;DRIVER=SQL Server;SERVER=" & ComputerName & ";DATABASE=RUILS_Temp;Uid=" & strUID & ";Pwd=" & strPWD
 
Set db = CurrentDb
 
For Each q In db.QueryDefs
 If q.Type = dbQSQLPassThrough Then
    q.Connect = strConnect
 End If
Next

BUT it seems to require a re-start of the Access 2007 database to commit these, in fact in my case it requires 2 re-starts as I have a login process.
I did read somewhere that the ODBC properies of a pass through are written to cache when the DB is open.
Is this correct or is there a way around this?

I'm doing this as I have multi companies using the same database and need to run a function on SQL Server views using SUSER_SNAME()

Thanks

Scott
 
I've not used MS Access in a couple of years; but as I recall in the past...

I actually deleted and rebuilt pass-through queries on the fly and had no problems. I did need a "Refresh" though. Look to see if there is a QueryDef Refresh or Database Refresh that will perform the commit for your purposes.

In the mean-time I will see if I can find my code; which may be on an old CD Archive somewhere...

Good Luck,


Steve Medvid
IT Consultant & Web Master

Chester County, PA Residents
Please Show Your Support...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top