If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Move values Multiselect Listbox
I have 1 form with a list box on it. The values chosen become criteria in a query- but I want to use a criteria of * if no values on the listbox are chosen. I almost figured it out. I put a text box on the same form and I want a "1" to show up if at least one value is chosen on the listbox, but if no values are chosen I want a "0" to show up. I'm going to base a macro off of this test box (use as a condition) any help would be appreciated.
Thanks, Mark -- MSS |
#2
|
|||
|
|||
Move values Multiselect Listbox
Assuming that the list box has its Multiselect property set to Simple or
Extended, put this code on the OnClick event of the list box: Private Sub ListBoxName_Click() Me.TextBoxName.Value = -(Me.ListBoxName.ItemsSelected.Count 0) End Sub Be sure that the default value of the textbox is set to 0 so that it will have your desired value if nothing is ever clicked or unclicked in the list box. Now, let me suggest a different approach for your macro. Let it use the Forms!FormName!ListBoxName.ItemsSelected.Count as its value instead of the value in the textbox. "Cut out the middle man." And then you don't need to VBA code on the list box's OnClick event either. -- Ken Snell MS ACCESS MVP "Mark Senibaldi" wrote in message ... I have 1 form with a list box on it. The values chosen become criteria in a query- but I want to use a criteria of * if no values on the listbox are chosen. I almost figured it out. I put a text box on the same form and I want a "1" to show up if at least one value is chosen on the listbox, but if no values are chosen I want a "0" to show up. I'm going to base a macro off of this test box (use as a condition) any help would be appreciated. Thanks, Mark -- MSS |
#3
|
|||
|
|||
Move values Multiselect Listbox
I used your suggested approach and it work.
Thanks alot. Your help is much appreciated. -- MSS "Ken Snell" wrote: Assuming that the list box has its Multiselect property set to Simple or Extended, put this code on the OnClick event of the list box: Private Sub ListBoxName_Click() Me.TextBoxName.Value = -(Me.ListBoxName.ItemsSelected.Count 0) End Sub Be sure that the default value of the textbox is set to 0 so that it will have your desired value if nothing is ever clicked or unclicked in the list box. Now, let me suggest a different approach for your macro. Let it use the Forms!FormName!ListBoxName.ItemsSelected.Count as its value instead of the value in the textbox. "Cut out the middle man." And then you don't need to VBA code on the list box's OnClick event either. -- Ken Snell MS ACCESS MVP "Mark Senibaldi" wrote in message ... I have 1 form with a list box on it. The values chosen become criteria in a query- but I want to use a criteria of * if no values on the listbox are chosen. I almost figured it out. I put a text box on the same form and I want a "1" to show up if at least one value is chosen on the listbox, but if no values are chosen I want a "0" to show up. I'm going to base a macro off of this test box (use as a condition) any help would be appreciated. Thanks, Mark -- MSS |
#4
|
|||
|
|||
Move values Multiselect Listbox
You're welcome.
-- Ken Snell MS ACCESS MVP "Mark Senibaldi" wrote in message ... I used your suggested approach and it work. Thanks alot. Your help is much appreciated. -- MSS "Ken Snell" wrote: Assuming that the list box has its Multiselect property set to Simple or Extended, put this code on the OnClick event of the list box: Private Sub ListBoxName_Click() Me.TextBoxName.Value = -(Me.ListBoxName.ItemsSelected.Count 0) End Sub Be sure that the default value of the textbox is set to 0 so that it will have your desired value if nothing is ever clicked or unclicked in the list box. Now, let me suggest a different approach for your macro. Let it use the Forms!FormName!ListBoxName.ItemsSelected.Count as its value instead of the value in the textbox. "Cut out the middle man." And then you don't need to VBA code on the list box's OnClick event either. -- Ken Snell MS ACCESS MVP "Mark Senibaldi" wrote in message ... I have 1 form with a list box on it. The values chosen become criteria in a query- but I want to use a criteria of * if no values on the listbox are chosen. I almost figured it out. I put a text box on the same form and I want a "1" to show up if at least one value is chosen on the listbox, but if no values are chosen I want a "0" to show up. I'm going to base a macro off of this test box (use as a condition) any help would be appreciated. Thanks, Mark -- MSS |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Howto: Filling in values based upon a particular cell | Eric Tubbs | Worksheet Functions | 6 | December 3rd, 2003 07:24 PM |
Using Datetime values as Category | Dave Shea | Charts and Charting | 1 | November 29th, 2003 04:58 AM |
How to read values off graph? | Connie | Worksheet Functions | 0 | November 14th, 2003 08:41 PM |