R
Rocky
First off, forgive the messy code, being a newbie, I know this is not tight.
My problem lies in the line:
"For Each varItem In strItemsSelectedList"
I get a data type mismatch error. I think the problem has something to do
with how access handles objects as opposed to variants. If I insert the non
variable code to call selected items from the list boxes, the sequence works.
The purpose of this code is to select choices from multiple list boxes which
will then be placed into a text box.
Public Sub ConcatenateProcedures()
Dim strformname As Object
Dim strproclistcode As Variant
Dim strproclistproc As Variant
Dim strItemsSelectedList As Variant
Dim strItemsSelCount As Variant
Dim varItem As Variant
strformname = "[form_frm" & strproclist
strproclistcode = "str" & strproclist & "code"
strproclistproc = "str" & strproclist & "proc"
strproclistcode = ""
strproclistproc = ""
varItem = ""
strItemsSelectedList = ""
strItemsSelCount = strformname & "!List0.ItemsSelected.Count"
strItemsSelectedList = strformname & "!List0.ItemsSelected"
' If no items selected, then nothing to do
If strItemsSelCount = 0 Then
Exit Sub
End If
' Loop through the items selected collection
For Each varItem In strItemsSelectedList
' Grab the procedure code and text columns for each selected item
strproclistcode = strproclistcode & strformname & "!List0.Column(1,
varItem)" & Chr$(44)
strproclistproc = strproclistproc & strformname & "!List0.Column(2,
varItem)" & Chr$(44)
Next varItem
' Throw away the extra comma on the "IN" string
strproclistcode = Left$(strproclistcode, Len(strproclistcode) - 1)
strproclistproc = Left$(strproclistproc, Len(strproclistproc) - 1)
Tx
Rocky
My problem lies in the line:
"For Each varItem In strItemsSelectedList"
I get a data type mismatch error. I think the problem has something to do
with how access handles objects as opposed to variants. If I insert the non
variable code to call selected items from the list boxes, the sequence works.
The purpose of this code is to select choices from multiple list boxes which
will then be placed into a text box.
Public Sub ConcatenateProcedures()
Dim strformname As Object
Dim strproclistcode As Variant
Dim strproclistproc As Variant
Dim strItemsSelectedList As Variant
Dim strItemsSelCount As Variant
Dim varItem As Variant
strformname = "[form_frm" & strproclist
strproclistcode = "str" & strproclist & "code"
strproclistproc = "str" & strproclist & "proc"
strproclistcode = ""
strproclistproc = ""
varItem = ""
strItemsSelectedList = ""
strItemsSelCount = strformname & "!List0.ItemsSelected.Count"
strItemsSelectedList = strformname & "!List0.ItemsSelected"
' If no items selected, then nothing to do
If strItemsSelCount = 0 Then
Exit Sub
End If
' Loop through the items selected collection
For Each varItem In strItemsSelectedList
' Grab the procedure code and text columns for each selected item
strproclistcode = strproclistcode & strformname & "!List0.Column(1,
varItem)" & Chr$(44)
strproclistproc = strproclistproc & strformname & "!List0.Column(2,
varItem)" & Chr$(44)
Next varItem
' Throw away the extra comma on the "IN" string
strproclistcode = Left$(strproclistcode, Len(strproclistcode) - 1)
strproclistproc = Left$(strproclistproc, Len(strproclistproc) - 1)
Tx
Rocky