Cristal Report? MS Access?
Kelloggs
If in ms access you can do it by code:
Function CreateSPT (SPTQueryName As String, SQLString As String, ConnectString As String)
'-----------------------------------------------
' FUNCTION: CreateSPT()
' PURPOSE:
' Creates an SQL pass-through query using the supplied arguments:
' SPTQueryName: the name of the query to create
' SQLString: the query's SQL string
' ConnectString: the ODBC connect string, this must be at
' least "ODBC;"
'-----------------------------------------------
Dim mydatabase As Database, myquerydef As QueryDef
Set mydatabase = DBENGINE.Workspaces(0).Databases(0)
Set myquerydef = mydatabase.CreateQueryDef(SPTQueryName)
myquerydef.connect = ConnectString
myquerydef.sql = SQLString
myquerydef.Close
End Function
the way to use the function is like this:
CreateSPT("Test", "Select * from authors", "ODBC;DSN=Red;Database=Pubs;USID=JOE;PWD=JOE")