Hey Guys,
I'm pretty new to VBA and have hit a snag where I don't know how to go forward. Your assistance/coaching will be greatly appreciated. I have a modal form with member data populated on the form load procedure on it. Then on a listBox that has "Multi Select" enabled, the user will make a selection of all the "codes" he wants to report on.
In a button "on-click" procedure I have the following code that runs through the listBox selections:
Dim strWhere As String
Dim ctl As Control
Dim varItem As Variant
'make sure a selection has been made
If Me.lstBulkExercise.ItemsSelected.Count = 0 Then
MsgBox "Must select at least 1 Exercise"
Exit Sub
End If
'add selected values to string
Set ctl = Me.lstBulkExercise
For Each varItem In ctl.ItemsSelected
strWhere = strWhere & "'" & ctl.ItemData(varItem) & "',"
Next varItem
'trim trailing comma
strWhere = Left(strWhere, Len(strWhere) - 1)
What I need assistance with:
I need to run a select query in the code WHERE the member number as the primary key AND "strWhere" values are run agains the table, and then have that displayed on a report. The problem is I don't know how to accomplish this and really want to find out how to get this done.
Your assistance is greatly appreciated.
Thanks
I'm pretty new to VBA and have hit a snag where I don't know how to go forward. Your assistance/coaching will be greatly appreciated. I have a modal form with member data populated on the form load procedure on it. Then on a listBox that has "Multi Select" enabled, the user will make a selection of all the "codes" he wants to report on.
In a button "on-click" procedure I have the following code that runs through the listBox selections:
Dim strWhere As String
Dim ctl As Control
Dim varItem As Variant
'make sure a selection has been made
If Me.lstBulkExercise.ItemsSelected.Count = 0 Then
MsgBox "Must select at least 1 Exercise"
Exit Sub
End If
'add selected values to string
Set ctl = Me.lstBulkExercise
For Each varItem In ctl.ItemsSelected
strWhere = strWhere & "'" & ctl.ItemData(varItem) & "',"
Next varItem
'trim trailing comma
strWhere = Left(strWhere, Len(strWhere) - 1)
What I need assistance with:
I need to run a select query in the code WHERE the member number as the primary key AND "strWhere" values are run agains the table, and then have that displayed on a report. The problem is I don't know how to accomplish this and really want to find out how to get this done.
Your assistance is greatly appreciated.
Thanks