A
Anne
I have two seperate requests for reports, the first report selects items
from a list box and prints the report. The second selects a date range, but
orginally asked to select an employee from a combobox.
I have been trying to combine the listbox selection with a date range
selection, but the results are not what I am asking for, neither the date
range or the names selected appear on the report. -The code is below
Can someone help?
Anne
Private Sub CmdPrint_Click()
Dim varSelected As Variant
Dim strSQL As String
For Each varSelected In Me!lstSelect.ItemsSelected
strSQL = strSQL & Me!lstSelect.ItemData(varSelected) & ","
Next varSelected
If strSQL <> "" Then
strSQL = "[EmployeeId] IN (" & Left(strSQL, Len(strSQL) - 1) & ")"
'''''''''''DoCmd.OpenReport "DetailbyEmplbyWeek", acViewPreview, ,
strSQL
----------------------this is where the list selection by itself
ended----------------
End If
If Not IsNull(Me!txtDateFrom) Then
strWhere = strWhere & " AND [WeDate] >= #" & _
CDate(Me!txtDateFrom) & "#"
End If
If Not IsNull(Me!txtdateto) Then
strWhere = strWhere & " AND [WeDate] <= #" & _
CDate(Me!txtdateto) & "#"
End If
DoCmd.OpenReport "DetailbyEmplbyWeek", acViewPreview, , strSQL
End Sub
from a list box and prints the report. The second selects a date range, but
orginally asked to select an employee from a combobox.
I have been trying to combine the listbox selection with a date range
selection, but the results are not what I am asking for, neither the date
range or the names selected appear on the report. -The code is below
Can someone help?
Anne
Private Sub CmdPrint_Click()
Dim varSelected As Variant
Dim strSQL As String
For Each varSelected In Me!lstSelect.ItemsSelected
strSQL = strSQL & Me!lstSelect.ItemData(varSelected) & ","
Next varSelected
If strSQL <> "" Then
strSQL = "[EmployeeId] IN (" & Left(strSQL, Len(strSQL) - 1) & ")"
'''''''''''DoCmd.OpenReport "DetailbyEmplbyWeek", acViewPreview, ,
strSQL
----------------------this is where the list selection by itself
ended----------------
End If
If Not IsNull(Me!txtDateFrom) Then
strWhere = strWhere & " AND [WeDate] >= #" & _
CDate(Me!txtDateFrom) & "#"
End If
If Not IsNull(Me!txtdateto) Then
strWhere = strWhere & " AND [WeDate] <= #" & _
CDate(Me!txtdateto) & "#"
End If
DoCmd.OpenReport "DetailbyEmplbyWeek", acViewPreview, , strSQL
End Sub