Listbox - bound column text field

Carrie

Registered User.
Local time
Today, 16:00
Joined
Jan 8, 2003
Messages
36
Hi

I've created a listbox and am using the following code

stWhat1 = "": stCriteria1 = ","
For Each vItm1 In Me!LstArchive.ItemsSelected
stWhat1 = stWhat1 & Me![LstArchive].Column(0, vItm1)
stWhat1 = stWhat1 & stCriteria1
Next vItm1
Me!txtCriteria1 = CStr(Left$(stWhat1, Len(stWhat1) - Len(stCriteria1)))

The problem is that my bound column is a text field. I'm really struggling on where to put my quotations so that I get the following with the In function
In('00638','00639').

Any help or pointing in right direction would be very much appreciated
Carrie
 
Carrie said:
Hi

I've created a listbox and am using the following code

stWhat1 = "": stCriteria1 = ","
For Each vItm1 In Me!LstArchive.ItemsSelected
stWhat1 = stWhat1 & Me![LstArchive].Column(0, vItm1)
stWhat1 = stWhat1 & stCriteria1
Next vItm1
Me!txtCriteria1 = CStr(Left$(stWhat1, Len(stWhat1) - Len(stCriteria1)))

The problem is that my bound column is a text field. I'm really struggling on where to put my quotations so that I get the following with the In function
In('00638','00639').

Any help or pointing in right direction would be very much appreciated
Carrie


Try it this way:

Code:
Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strCriteria As String
    Set frm = Form!frmMyForm
    Set ctl = frm!lLstArchive
    strCriteria = ""
    For Each varItem In ctl.ItemsSelected
        strCriteria = strCriteria & "'" & ctl.ItemData(varItem) & "', "
    Next varItem

    strCRiteria=left$(strCriteria,len(strSQL)-2))
 
Thank you!

That worked perfectly!

Carrie
 

Users who are viewing this thread

Back
Top Bottom