J
Jason
Hi,
I have this function where i create temporary pass-through-queries.
However, once the query is created the function fails if i try to use it
again.
Can someone help me adjust the code so it will check if the query exists.
Function CreateSPT(SPTQueryName As String, SQLString As String)
Dim mydatabase As DAO.Database
Dim myquerydef As DAO.QueryDef
Set mydatabase = DBEngine.Workspaces(0).Databases(0)
Set myquerydef = mydatabase.CreateQueryDef(SPTQueryName)
myquerydef.Connect = GetODBCConnection
myquerydef.SQL = SQLString
myquerydef.Close
End Function
I have this function where i create temporary pass-through-queries.
However, once the query is created the function fails if i try to use it
again.
Can someone help me adjust the code so it will check if the query exists.
Function CreateSPT(SPTQueryName As String, SQLString As String)
Dim mydatabase As DAO.Database
Dim myquerydef As DAO.QueryDef
Set mydatabase = DBEngine.Workspaces(0).Databases(0)
Set myquerydef = mydatabase.CreateQueryDef(SPTQueryName)
myquerydef.Connect = GetODBCConnection
myquerydef.SQL = SQLString
myquerydef.Close
End Function