I'm using MS Access 2003.
I have a custom function that opens a recordset using a temporary pass-thru QueryDef object. Here's the guts of my code:
I'm just wondering whether I should explicitly delete or close the temp QueryDef object, and if so, where? If yes, I'm thinking that I'd want to do it right after
but can I do that? (I thought the Set statement should be the last of the function.)
I notice that in the example on the following page:
http://msdn.microsoft.com/en-us/library/office/ff845129.aspx
the temp QueryDef is not deleted or closed.
Since this function can be run many times in a given session, I'd want to ensure that the temp QueryDef objects are being cleaned up as I go.
Thanks for any help you can give.
Wayne
I have a custom function that opens a recordset using a temporary pass-thru QueryDef object. Here's the guts of my code:
Code:
Public Function OpenRecordsetPassThru(ByVal pstrSQL As String, Optional ByVal pstrDatabase As String = "ORACLE", ...) As Recordset
On Error GoTo OpenRecordsetPassThruErr
Dim db As Database
Set db = CodeDb
Dim qdTemp As DAO.QueryDef
Dim strConnect As String
Dim lngOdbcTimeout As Long
' Main Line
Select Case pstrDatabase
Case "DYNAMICS"
strConnect = cstrDynamicsConnect
lngOdbcTimeout = 60
Case Else 'Oracle
strConnect = GetOracleConnect
lngOdbcTimeout = 3600
End Select
' Create a temporary pass-thru query
Set qdTemp = db.CreateQueryDef("")
' Set properties of temp pass-thru query
qdTemp.Connect = strConnect
qdTemp.ODBCTimeout = lngOdbcTimeout
qdTemp.SQL = pstrSQL
qdTemp.ReturnsRecords = True
Set OpenRecordsetPassThru = qdTemp.OpenRecordset(pintType, pintOptions)
...
I'm just wondering whether I should explicitly delete or close the temp QueryDef object, and if so, where? If yes, I'm thinking that I'd want to do it right after
Code:
Set OpenRecordsetPassThru = qdTemp.OpenRecordset(pintType,
I notice that in the example on the following page:
http://msdn.microsoft.com/en-us/library/office/ff845129.aspx
the temp QueryDef is not deleted or closed.
Since this function can be run many times in a given session, I'd want to ensure that the temp QueryDef objects are being cleaned up as I go.
Thanks for any help you can give.
Wayne