VB code for Multilistbox doesn't work.

mixedguy

Registered User.
Local time
Today, 02:14
Joined
Jun 12, 2002
Messages
52
This code is embedded in the event procedure of a button. When I select a Program and year and click the button the error message I receive is as follows: "Run Time error '438' Object doesnt support this property or method." Can someone please tell me what I'm doing wrong?

The code I'm using is below...
Thanks in advance!!!!


Private Sub Command29_Click()
Dim StrWhere As String
Dim varItem As Variant

If Me.tog_BusSize = True Then
StrWhere = "("

If ((Me.lst_Prog.ItemsSelected.Count) > 0 And _
(Me.lst_FY.ItemsSelected.Count) > 0 And _
(Me.lst_Qtr.ItemsSelected.Count) = 0 And _
(Me.lst_Proj.ItemsSelected.Count) = 0 And _
(Me.lst_Output.ItemsSelected.Count) = 0) Then

For Each varItem In Me![lst_Prog].ItemsSelected
StrWhere = StrWhere & "Prod_Title =" _
& Chr(39) & Me![lst_Prog].Column(0, varItem) & Chr(39) & " Or "
Next varItem

StrWhere = Left(StrWhere, Len(StrWhere) - 4) & ")And("

For Each varItem In Me![lst_FY].Itemselected
StrWhere = StrWhere & "FY =" _
& Chr(39) & Me![lst_FY].Column(0, varItem) & Chr(39) & "Or"
Next varItem

End If

StrWhere = Left(StrWhere, Len(StrWhere) - 4) & ")"
DoCmd.OpenReport "rptBus_Size", acViewPreview, , StrWhere
End If

End Sub
 
Can you point to the line(s) that is /arecausing the problem?
 
error line...

At the beginning of this code is where the error occurs.


For Each varItem In Me![lst_FY].Itemselected
StrWhere = StrWhere & "FY =" _
& Chr(39) & Me![lst_FY].Column(0, varItem) & Chr(39) & "Or"
Next varItem

End If
 
You're missing an "S":

For Each varItem In Me![lst_FY].ItemsSelected

Also looks like you might be missing spaces around the " Or "
 

Users who are viewing this thread

Back
Top Bottom