パススルー クエリの Connect プロパティを見てください。Connect with VBA を変更できます。この手順では、prod と dev のデータベース接続を切り替えます。
Public Sub SwitchPassThroughConnection(ByVal pQuery As String, ByVal pTarget As String)
Dim db As DAO.Database
Dim qdef As DAO.QueryDef
Dim strConnect As String
Dim blnError As Boolean
Set db = CurrentDb()
Select Case pTarget
Case "dev"
strConnect = "ODBC;DRIVER={PostgreSQL Unicode};DATABASE=dev;SERVER=cmpq;" & _
"PORT=5432;UID=hans;PWD=changeme;CA=d;A6=;A7=100;A8=4096;" & _
"B0=255;B1=8190;BI=0;C2=dd_;CX=1b502bb;A1=7.4"
Case "prod"
strConnect = "ODBC;DRIVER={PostgreSQL Unicode};DATABASE=prod;SERVER=cmpq;" & _
"PORT=5432;UID=hans;PWD=changeme;CA=d;A6=;A7=100;A8=4096;" & _
"B0=255;B1=8190;BI=0;C2=dd_;CX=1b502bb;A1=7.4"
Case Else
blnError = True
MsgBox "Unrecognized target."
End Select
If Not blnError Then
Set qdef = db.QueryDefs(pQuery)
qdef.Connect = strConnect
qdef.Close
End If
Set qdef = Nothing
Set db = Nothing
End Sub