ms access 2003 - Changing connection params when using pass-through query -


I have an Access 2003 application that I would like to create a report to use stored procedures through pass-through queries . Everything works fine with one exception when I specify the stored procedure to use for the passed query, then I must select the DSN to provide the database connection information. The stored procedure used in the pass-through query requires to be able to change the connection code through the code . It is because I switch from the application to the development, output, test environment I can do

Currently all of my data access (additional, update, editing) use ADO and I create connection strings through VBA code. I am unsure of how to change the connection information of the pass-through query via code. Any ideas? Thank you.

View the connected property of your pass-through query You can change the connect with VBA. This process switches between Prod and Dev database connection.

  Public sub-switch deficit-to-connection (biline in the form of strings, biline in the form of string), DAO as DAP. Database Dim Qdef DAO Select Boolean set db = CurrentDb () case as a bln error; pTarget case "dev" strConnect = "ODBC; driver = {PostgreSQL Unicode}; database = dev; server = cmpq;" & Amp; _ "Ports = 5432; uid = swan; pwd = changeme; ca = d; a6 = a7 = 100; a8 = 4096;" & Amp; _ "B = 255; b1 = 8190; bi = 0; c2 = dd__; cx = 1b502bb; a1 = 7.4" case "prod" strconct = "obdb; driver = {postgrax sql unicode}; Database = Prod; Server = CMPQ; "& Amp; _ "Ports = 5432; uid = swan; pwd = changeme; ca = d; a6 = a7 = 100; a8 = 4096;" & Amp; _ "B = 255; b1 = 8190; bi = 0; c2 = dd_; cx = 1b 502bb; a1 = 7.4" case isl bellarroll = true messbox "unrecognized target." Choose end if not blnError then set qdef = db.QueryDefs (pQuery) qdef.Connect = strConnect qdef.Close closing if set qdef = nothing set db = nothing end sub  
< / Div>

Comments