I have LISTBOX62 with several Dealer names in it for multiple choose( for example Dealer1, Dealer2, Dealer3, ...)I now want to multiple select the Dealer names in the LISTBOX62, and then click a BUTTON32 to open a FORM38 with the filter (criteria) of the selected Dealer names.How to write this VBA? Thank you.P.S. I have tried the following VBA, but can't work:Dim varItem As VariantDim itemList As StringFor Each varItem In List62.ItemsSelected itemList = itemList & "'" & List62.ItemData(varItem) & "',"Next varItemIf itemList <> "" Then itemList = Left(itemList, Len(itemList) - 1) DoCmd.OpenForm "FORM38" Forms!FORM38.Filter = "DEALERNAME like '" & ItemList & "'" Forms!FORM38.FilterOn = TrueEndIf
|
|
1
|
|
|
|
Reply
|
Martin
|
3/8/2007 5:57:34 AM |
|
That might work if you change the 2nd last line to: Forms!FORM38.Filter = "[DEALERNAME] IN (" & ItemList & ")"If that doesn't work, open your table in deisgn view, and find what the Data Type of the DealerName field is. If Number (typically because it is a combo looking up another table), the code won't work unless you concatenate the numbers (not the names), and omit the quotes.-- Allen Browne - Microsoft MVP. Perth, Western AustraliaTips for Access users - http://allenbrowne.com/tips.htmlReply to group, rather than allenbrowne at mvps dot org."Martin (Martin Lee)" <lajitong888@21cn.com> wrote in messagenews:%23q8MpaUYHHA.4264@TK2MSFTNGP05.phx.gbl...>I have LISTBOX62 with several Dealer names in it for multiple choose( for >example Dealer1, Dealer2, Dealer3, ...)>> I now want to multiple select the Dealer names in the LISTBOX62, and then > click a BUTTON32 to open a FORM38 with the filter (criteria) of the > selected Dealer names.>> How to write this VBA? Thank you.>> P.S. I have tried the following VBA, but can't work:>> Dim varItem As Variant> Dim itemList As String> For Each varItem In List62.ItemsSelected> itemList = itemList & "'" & List62.ItemData(varItem) & "',"> Next varItem>> If itemList <> "" Then> itemList = Left(itemList, Len(itemList) - 1)>> DoCmd.OpenForm "FORM38"> Forms!FORM38.Filter = "DEALERNAME like '" & ItemList & "'"> Forms!FORM38.FilterOn = True>> EndIf
|
|
0
|
|
|
|
Reply
|
Allen
|
3/8/2007 6:59:14 AM
|
|
Hi Allen, your idea can't work.And te DealerName field is text type.Thanks anyway.Martin"Martin (Martin Lee)" <lajitong888@21cn.com> д����Ϣ����:%23q8MpaUYHHA.4264@TK2MSFTNGP05.phx.gbl...>I have LISTBOX62 with several Dealer names in it for multiple choose( for >example Dealer1, Dealer2, Dealer3, ...)>> I now want to multiple select the Dealer names in the LISTBOX62, and then > click a BUTTON32 to open a FORM38 with the filter (criteria) of the > selected Dealer names.>> How to write this VBA? Thank you.>>> P.S. I have tried the following VBA, but can't work:>> Dim varItem As Variant> Dim itemList As String> For Each varItem In List62.ItemsSelected> itemList = itemList & "'" & List62.ItemData(varItem) & "',"> Next varItem>> If itemList <> "" Then> itemList = Left(itemList, Len(itemList) - 1)>> DoCmd.OpenForm "FORM38"> Forms!FORM38.Filter = "DEALERNAME like '" & ItemList & "'"> Forms!FORM38.FilterOn = True>> EndIf>>>>>>>
|
|
0
|
|
|
|
Reply
|
Martin
|
3/8/2007 8:48:19 AM
|
|
It the field is a Text data type, and the bound column of the list box is a text data type, then the suggested line should work, i.e. Forms!FORM38.Filter = "[DEALERNAME] IN (" & ItemList & ")"-- Allen Browne - Microsoft MVP. Perth, Western AustraliaTips for Access users - http://allenbrowne.com/tips.htmlReply to group, rather than allenbrowne at mvps dot org."Martin (Martin Lee)" <lajitong888@21cn.com> wrote in messagenews:efrvF6VYHHA.2448@TK2MSFTNGP02.phx.gbl...> Hi Allen, your idea can't work.>> And te DealerName field is text type.>> Thanks anyway.>> Martin>>> "Martin (Martin Lee)" <lajitong888@21cn.com> > д����Ϣ����:%23q8MpaUYHHA.4264@TK2MSFTNGP05.phx.gbl...>>I have LISTBOX62 with several Dealer names in it for multiple choose( for >>example Dealer1, Dealer2, Dealer3, ...)>>>> I now want to multiple select the Dealer names in the LISTBOX62, and then >> click a BUTTON32 to open a FORM38 with the filter (criteria) of the >> selected Dealer names.>>>> How to write this VBA? Thank you.>>>>>> P.S. I have tried the following VBA, but can't work:>>>> Dim varItem As Variant>> Dim itemList As String>> For Each varItem In List62.ItemsSelected>> itemList = itemList & "'" & List62.ItemData(varItem) & "',">> Next varItem>>>> If itemList <> "" Then>> itemList = Left(itemList, Len(itemList) - 1)>>>> DoCmd.OpenForm "FORM38">> Forms!FORM38.Filter = "DEALERNAME like '" & ItemList & "'">> Forms!FORM38.FilterOn = True>> EndIf
|
|
0
|
|
|
|
Reply
|
Allen
|
3/8/2007 9:35:28 AM
|
|
|
3 Replies
897 Views
(page loaded in 0.047 seconds)
Similiar Articles: VBA-- Open a Form with filter accoding to LISTBOX multiple choices ...I have LISTBOX62 with several Dealer names in it for multiple choose( for example Dealer1, Dealer2, Dealer3, ...)I now want to multiple select the Dea... Listbox to open a form (primary key text) - microsoft.public ...Listbox VBA Coding - microsoft.public.access Listbox to open a form (primary key text) - microsoft.public ... ... Using listbox to filter data... OpenForm method can be tricky ... filter form by listbox selection - microsoft.public.access ...VBA-- Open a Form with filter accoding to LISTBOX multiple choices ..... and then click a BUTTON32 to open a FORM38 with the filter (criteria) of the selected ... Can VBA open a form in an already open database? - microsoft ...VBA-- Open a Form with filter accoding to LISTBOX multiple choices ... VBA-- Open a Form with filter accoding to LISTBOX multiple choices ... How to filter listbox data in ... How to filter listbox data in a form? - microsoft.public.excel ...VBA-- Open a Form with filter accoding to LISTBOX multiple choices ... How to filter listbox data in a form? - microsoft.public.excel ... VBA-- Open a Form with filter ... Filter Report by Form - VBA Code - microsoft.public.access.reports ...VBA-- Open a Form with filter accoding to LISTBOX multiple choices ... Filter Report by Form - VBA Code - microsoft.public.access.reports ... VBA-- Open a Form with filter ... Filtering a multiple item form - microsoft.public.access ...VBA-- Open a Form with filter accoding to LISTBOX multiple choices ... VBA-- Open a Form with filter accoding to LISTBOX multiple choices ... VBA-- Open a Form with filter ... Access: select multiple records in a form, process list in VBA ...VBA-- Open a Form with filter accoding to LISTBOX multiple choices ... Access: select multiple records in a form, process list in VBA ... VBA-- Open a Form with filter ... Listbox VBA Coding - microsoft.public.accessVBA-- Open a Form with filter accoding to LISTBOX multiple choices ... I have LISTBOX62 with several Dealer names in it for multiple choose( for example Dealer1, Dealer2 ... Multiple-criteria search on form, to open form - microsoft.public ...VBA-- Open a Form with filter accoding to LISTBOX multiple choices ... You can combine multiple conditions in the ... VBA-- Open a Form with filter accoding to LISTBOX ... VBA-- Open a Form with filter accoding to LISTBOX multiple choices ...I have LISTBOX62 with several Dealer names in it for multiple choose( for example Dealer1, Dealer2, Dealer3, ...)I now want to multiple select the Dea... VBA-- Open a Form with filter accoding to LISTBOX multiple choicesdatabase.itags.org: Microsoft Access question: VBA-- Open a Form with filter accoding to LISTBOX multiple choices, created at:Sun, 01 Jun 2008 10:32:00 GMT with 824 ... VBA-- Open a Form with filter accoding to LISTBOX multiple choicesI have LISTBOX62 with several Dealer names in it for multiple choose( for example Dealer1, Dealer2, Dealer3, ...) I now want to multiple select the Use listboxes with multiple choices using VBA in Microsoft Excel» Use listboxes with multiple choices using VBA in Microsoft Excel ... The list with the chosen items in a multiple choice listbox is stored in ... List Boxes (ListBox) in ExcelLesson 30: VBA for Excel list boxes (listbox). One or many columns to show and choose from. Single choice or multiple choices. 7/20/2012 8:13:47 PM
|