D J
asked on
MS Access Why is my list box VBA code seem to be one number off?
See attached database.
The VBA code below opens a report with the selection(s) from a list box, the issue:
-If I select customer 5, the report output is customer 4
-if I select customer 2, the report output is customer 1
Please note the report has a sub-form to display other customers that are associated with that project:
Selected Customer 8 & 11 in the list box, click the report button:
Report (report will display all the projects with Customer 8 & 11)
Project 1
Customer 5 (sub-form in report)
Customer 8
Customer 10
Project 2
Customer 11 (sub-form in report)
Customer 12
Customer 13
The VBA code below opens a report with the selection(s) from a list box, the issue:
-If I select customer 5, the report output is customer 4
-if I select customer 2, the report output is customer 1
Please note the report has a sub-form to display other customers that are associated with that project:
Selected Customer 8 & 11 in the list box, click the report button:
Report (report will display all the projects with Customer 8 & 11)
Project 1
Customer 5 (sub-form in report)
Customer 8
Customer 10
Project 2
Customer 11 (sub-form in report)
Customer 12
Customer 13
Private Sub Command2_Click()
Dim var As Variant
Dim where As String
For Each var In Me.List0.ItemsSelected
where = var & "," & where
Next var
If Len(where) > 0 Then
where = Left(where, Len(where) - 1)
DoCmd.OpenReport "Projects Reportwithsub", acViewPreview, , "CustID IN (" & where & ")"
End If
End Sub
ReportListBox---Copy-.accdb
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER