M
mlwallin
I have a large number of SQL pass-thru queries that look at a particular SQL
server and database. For an extensive upgrade, I'm setting up a test
environment on a development server. Rather than going in to change each
connect string, then going back in to change it back again later, is there a
way I can have the server option in the connect string point to a variable,
so I can just "flip the switch" from one server to another?
Here's my routine that formats the pass through:
Public Sub PassThroughFixup(ByVal strQdfName As String, strSQL As String,
Optional varConnect As Variant, Optional fRetRecords As Boolean = True)
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strConnect As String
Set db = CurrentDb
Set qdf = db.QueryDefs(strQdfName)
If IsMissing(varConnect) Then
strConnect = qdf.Connect
Else
strConnect = CStr(varConnect)
End If
qdf.Connect = strConnect
qdf.ReturnsRecords = fRetRecords
qdf.SQL = strSQL
End Sub
and here's an example of how I call it:
Dim stDocName As String
Dim stSQL As String
stSQL = "OneOrAllConsults " & [txtPatientID] & ",'" & [cboEncounterID] &
"'"
stDocName = "qsptOneOrAllConsults"
Call PassThroughFixup(stDocName, stSQL)
stDocName = "rptOneOrAllConsults"
DoCmd.OutputTo acOutputReport, stDocName, acFormatSNP, , True
server and database. For an extensive upgrade, I'm setting up a test
environment on a development server. Rather than going in to change each
connect string, then going back in to change it back again later, is there a
way I can have the server option in the connect string point to a variable,
so I can just "flip the switch" from one server to another?
Here's my routine that formats the pass through:
Public Sub PassThroughFixup(ByVal strQdfName As String, strSQL As String,
Optional varConnect As Variant, Optional fRetRecords As Boolean = True)
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strConnect As String
Set db = CurrentDb
Set qdf = db.QueryDefs(strQdfName)
If IsMissing(varConnect) Then
strConnect = qdf.Connect
Else
strConnect = CStr(varConnect)
End If
qdf.Connect = strConnect
qdf.ReturnsRecords = fRetRecords
qdf.SQL = strSQL
End Sub
and here's an example of how I call it:
Dim stDocName As String
Dim stSQL As String
stSQL = "OneOrAllConsults " & [txtPatientID] & ",'" & [cboEncounterID] &
"'"
stDocName = "qsptOneOrAllConsults"
Call PassThroughFixup(stDocName, stSQL)
stDocName = "rptOneOrAllConsults"
DoCmd.OutputTo acOutputReport, stDocName, acFormatSNP, , True