I have a select query which has an input parameter in the where clause. I want to run this query and use the results as a recordset. I have already set the create query definition object. How can I run this query without using a hidden form.Here is the preparation part of the code
and here is the code trying to use it as a recordset:
Any help is appreciated.
Code:
Sub PrepareExport()
'--------------------------------------------------------------------------------
' Get input from user and Open the output txt file using Stream number 2
'--------------------------------------------------------------------------------
Dim Out As Variant
Dim SEL As String
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Set db = CurrentDb
Set qdf = db.CreateQueryDef
Dim SelQy As QueryDef
Dim SQLStatement As String
Dim sterm As String
SQLStatement = "SELECT TelephoneAAA.* FROM TelephoneAAA " & _
"WHERE (TelephoneAAA.SOYADI Like '*" & sterm & "*')" & _
"or (TelephoneAAA.ADI Like '*" & sterm & "*')" & _
"or (TelephoneAAA.ADRES Like '*" & sterm & "*')" & _
"or (TelephoneAAA.SEL Like '*" & sterm & "*')" & _
"ORDER BY TelephoneAAA.SOYADI, TelephoneAAA.ADI, TelephoneAAA.TEL;"
Set qdf = CurrentDb.CreateQueryDef(SelQy, SQLStatement)
Code:
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SelQy")
Any help is appreciated.