I have two list boxes on a form, one to drive the report selection and one to filter the data. I have the following statement:
Private Sub GraphListBox_AfterUpdate()
stDocName = Me.GraphListBox
stDocName2 = Me.FacilityUnitListBox
DoCmd.OpenReport stDocName, [acViewPreview], , "FacilityUnit =" & stDocName2
End Sub
The GraphListBox refers to the report and FacilityUnitListBox refers to the unit to filter the report.
The correct report pulls and the filter recognizes the FacilityUnitListBox selection correctly, but I keep getting a syntax error for the filter section of the DoCmd. Have tried variations on the syntax but can't seem to lock it down. The above is the closest I get and is exactly as defined in the Access help. It works if I hard code the facility unit as: "FacilityUnit = 3A" but need the staff to pick from a list for a broader selection.
Any suggestions, it's driving me nuts!!
Private Sub GraphListBox_AfterUpdate()
stDocName = Me.GraphListBox
stDocName2 = Me.FacilityUnitListBox
DoCmd.OpenReport stDocName, [acViewPreview], , "FacilityUnit =" & stDocName2
End Sub
The GraphListBox refers to the report and FacilityUnitListBox refers to the unit to filter the report.
The correct report pulls and the filter recognizes the FacilityUnitListBox selection correctly, but I keep getting a syntax error for the filter section of the DoCmd. Have tried variations on the syntax but can't seem to lock it down. The above is the closest I get and is exactly as defined in the Access help. It works if I hard code the facility unit as: "FacilityUnit = 3A" but need the staff to pick from a list for a broader selection.
Any suggestions, it's driving me nuts!!