Make temp query so can preview report

B

Becky

I use the following code to filter a subform on my
form. I want to be able to preview the result in a report.
How do I change this to a tempQuery? Or is there a better
way to do this.

Private Sub cmdSearch_Click()
Dim strSQL As String
Dim strValue As String

If togAll Then
strSQL = "Select * from qrySchedule "
Else
strSQL = "Select * from qrySchedule Where [" & Me!
[cboField] & "] "
strValue = Trim(Nz(Me![txtValue]))
Select Case Me![cboSearchType]
Case 1: 'Search in the beginning
strSQL = strSQL & "Like '" & strValue & "*' "
Case 2: 'Search anywhere
strSQL = strSQL & "Like '*" & strValue
& "*' "
End Select
End If

Call fnSort(strSQL) 'Add the sort criteria and change
the recordsource

End Sub


Thanks,
Becky
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top