Hi all,
I have a form that has a list box with all the employees names and a command button that when clicked, will open a report for each selected employee.
Problem is that it only runs the report on the last name selected on the form. Can anyone tell me what I'm missing in my code?
Function NameList() As String
Dim Itm As Variant
Dim ListNames As Variant
NameList = "("
For Each Itm In lstNames.ItemsSelected
NameList = ListNames & Chr(34) & lstNames.ItemData(Itm) & Chr(34) & ", "
Next
NameList = Left(NameList, Len(NameList) - 2) & ""
If Len(NameList) = 2 Then
NameList = ""
Else
NameList = "Employee_Name In( " & NameList
End If
End Function
Private Sub Command2_Click()
DoCmd.OpenReport "FinalWorksheetRPT", acViewPreview, , NameList
End Sub
I really appreciate any help.
Thanks, CindiN
I have a form that has a list box with all the employees names and a command button that when clicked, will open a report for each selected employee.
Problem is that it only runs the report on the last name selected on the form. Can anyone tell me what I'm missing in my code?
Function NameList() As String
Dim Itm As Variant
Dim ListNames As Variant
NameList = "("
For Each Itm In lstNames.ItemsSelected
NameList = ListNames & Chr(34) & lstNames.ItemData(Itm) & Chr(34) & ", "
Next
NameList = Left(NameList, Len(NameList) - 2) & ""
If Len(NameList) = 2 Then
NameList = ""
Else
NameList = "Employee_Name In( " & NameList
End If
End Function
Private Sub Command2_Click()
DoCmd.OpenReport "FinalWorksheetRPT", acViewPreview, , NameList
End Sub
I really appreciate any help.
Thanks, CindiN