|
-
Jun 13th, 2006, 12:54 PM
#1
Thread Starter
New Member
microsoft access - list box to build criteria
I am using a form in Microsoft Access that I'm trying to use to create a criteria statement for a query. In the list box, I have the following code entered as After Update:
Private Sub market_nm_AfterUpdate()
Dim strFilter As String
Dim varItem
strFilter = "In("
For Each varItem In market_nm.ItemsSelected
strFilter = strFilter & """ & varItem.Value & "","
Next varItem
strFilter = Left(strFilter, Len(strFilter) - 1)
strFilter = strFilter & ")"
txtFilter = strFilter
The idea is that it will create the following statement:
In("list_item1","list_item2","etc.")
But when I try to use that as my query filter (by setting the criteria line in the related query field to [forms]![form1]![market_nm],I get no results even though I know that the values in the list box are definitely in the file.
Do you know what is going wrong wtih that VBA code to prevent it from correctly forming the criteria "in" list?
Thanks,
Steven
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|