Dear Maquis,
This is cool, but would there be any way to sort the report by choosing "*" to show all records in a report for a client, task status, or employee? Is there any way to select * within one combo box and have it sort by that particular combo box, such as employee?
Here is what I have right now. It resolves based off of a Print Button.
Private Sub btnPrintToPrinter_Click()
On Error GoTo Err_btnPrintToPrinter_Click
Dim mRptName As String
Dim mWhereClause As String, mWhereClauseUsed As Integer
Dim mRptDest As Integer
Dim mRptPrints As Integer
Select Case Me![PrinterDestination]
Case 1 ' Destination is Screen
mRptDest = acPreview
Case 2 ' Destination is MS Word
mRptDest = 0
Case 3 ' Destination is printer
mRptDest = acNormal
End Select
Dim myDB As Database, MyQuery As QueryDef
Set myDB = DBEngine.Workspaces(0).Databases(0)
mRptName = "rptTaskListing"
Set MyQuery = myDB.QueryDefs("qryTaskSelector"

MyQuery.SQL = "SELECT DISTINCT qryTasks.* FROM qryTasks"
If [txtDateFrom] > "" And IIf(IsNull([txtDateTo]), "", [txtDateTo]) = "" Then
[txtDateTo] = [txtDateFrom]
End If
mWhereClauseUsed = 0
mWhereClause = ""
If [cboTaskStatus] > "" Or [cboTaskStatus] <> "*" Then
mWhereClauseUsed = -1
Select Case cboTaskStatus
Case "New", "Hold", "In Process", "Follow-up", "Completed", "Cancelled"
mWhereClause = mWhereClause + "([Status]='" + [cboTaskStatus] + "')"
Case "All Open"
mWhereClause = mWhereClause + "Not([Status]='Completed' or [Status]='Cancelled')"
Case "All Closed"
mWhereClause = mWhereClause + "([Status]='Completed' or [Status]='Cancelled')"
Case "*"
DoCmd.ShowAllRecords
End Select
End If
If [cboClient] > "" Then
If mWhereClauseUsed = -1 Then
mWhereClause = mWhereClause + " AND "
End If
mWhereClauseUsed = -1
mWhereClause = mWhereClause + "([C_LinkCode]=" + [cboClient] + "

"
End If
If [cboEmployee] > "" Or [cboEmployee] <> "*" Then
mWhereClauseUsed = -1
Select Case cboEmployee
Case "ACC"
mWhereClause = mWhereClause + "Not([EmployeeAssigned]='ANY' or [EmployeeAssigned]='CCC' or [EmployeeAssigned]='DC' or [EmployeeAssigned]= 'DR' or [EmployeeAssigned]= 'GM' or [EmployeeAssigned]='JF')"
End Select
'If mWhereClauseUsed = -1 Then
'mWhereClause = mWhereClause + "And"
'End If
'mWhereClauseUsed = -1
'mWhereClause = mWhereClause + "([EmployeeAssigned]='" + [cboEmployee] + "')"
End If
If [txtDateFrom] > "" Then
If mWhereClauseUsed = -1 Then
mWhereClause = mWhereClause + " AND "
End If
mWhereClauseUsed = -1
mWhereClause = mWhereClause + "([DateRequested]>=#" + Str([txtDateFrom]) + "#)"
End If
If [txtDateTo] > "" Then
If mWhereClauseUsed = -1 Then
mWhereClause = mWhereClause + " AND "
End If
mWhereClauseUsed = -1
mWhereClause = mWhereClause + "([DateRequested]<=#" + Str([txtDateTo]) + "#)"
End If
If mWhereClause > "" Then
MyQuery.SQL = MyQuery.SQL + " WHERE " + mWhereClause
End If
MyQuery.SQL = MyQuery.SQL + ";"
MyQuery.Close
For mRptPrints = 1 To Me.[NumCopies]
Select Case Me.PrinterDestination
Case 2
'The following line "exports" the report to a word document (*.RTF) and starts word.
'DoCmd OutputTo acREPORT, mRptName, acFORMATRTF, IIf(Left(gUserID, 4) = "DCOH", "C:\", "M:\DATA\"

& Mid(mRptName, 4, 8) + ".RTF", True
DoCmd.OutputTo acReport, mRptName, acFormatRTF, gUserTempDir & Mid(mRptName, 4, 8) + ".RTF", True
Case 1, 3
DoCmd.OpenReport mRptName, mRptDest
cboTaskStatus = ""
cboClient = ""
cboEmployee = ""
Case 4
'The following line "exports" the report to a text file (*.TXT).
DoCmd.OutputTo acReport, mRptName, acFormatTXT, IIf(Left(gUserID, 4) = "DCOH", "C:\", gUserTempDir) & Mid(mRptName, 4, 8) + ".RTF", True
End Select
Next
Exit_btnPrintToPrinter_Click:
Exit Sub
Err_btnPrintToPrinter_Click:
MsgBox "Error #" & Err.Number & ": " & Err.Description
Resume Exit_btnPrintToPrinter_Click
End Sub