Hi all,
I have a form w/ a listbox that allows me to select an "RMA#", then click a button to open another form with the RMA details. I wanted to make this a multiselect listbox, and have it open the form and allow viewing/editing of ONLY the slected records. I got some code from a book called " Access 2003, inside out by John Viescas". Great book so far. I am trying to modify his code but seem to be stuck.
This is what i have so far: StatusList = my listbox
Private Sub lookup_Click()
Dim strWhere As String, varItem As Variant
' Request to edit items selected in the list box
' If no items selected, then nothing to do
If Me!StatusList.ItemsSelected.Count = 0 Then Exit Sub
' Loop through the items selected collection
For Each varItem In Me.StatusList.ItemsSelected
'Grab the RMA# column for each selected item
strWhere = strWhere & Me.StatusList.Column(0, varItem)
Next varItem
' Open the RMA form filtered on the selected RMA#'s
strWhere = "[RMA#] IN (" & strWhere & ")"
DoCmd.OpenForm FormName:="InHouseRMADetail", WhereCondition:=strWhere
End Sub
When i run this, I receive "Runtime error 2501, the openform action was cancelled. When i debug it leaves me at the red line above.
Any help would be appreciated.
Kevin
I have a form w/ a listbox that allows me to select an "RMA#", then click a button to open another form with the RMA details. I wanted to make this a multiselect listbox, and have it open the form and allow viewing/editing of ONLY the slected records. I got some code from a book called " Access 2003, inside out by John Viescas". Great book so far. I am trying to modify his code but seem to be stuck.
This is what i have so far: StatusList = my listbox
Private Sub lookup_Click()
Dim strWhere As String, varItem As Variant
' Request to edit items selected in the list box
' If no items selected, then nothing to do
If Me!StatusList.ItemsSelected.Count = 0 Then Exit Sub
' Loop through the items selected collection
For Each varItem In Me.StatusList.ItemsSelected
'Grab the RMA# column for each selected item
strWhere = strWhere & Me.StatusList.Column(0, varItem)
Next varItem
' Open the RMA form filtered on the selected RMA#'s
strWhere = "[RMA#] IN (" & strWhere & ")"
DoCmd.OpenForm FormName:="InHouseRMADetail", WhereCondition:=strWhere
End Sub
When i run this, I receive "Runtime error 2501, the openform action was cancelled. When i debug it leaves me at the red line above.
Any help would be appreciated.
Kevin