A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Move values Multiselect Listbox



 
 
Thread Tools Display Modes
  #1  
Old August 3rd, 2004, 09:11 PM
Mark Senibaldi
external usenet poster
 
Posts: n/a
Default 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  
Old August 4th, 2004, 01:50 AM
Ken Snell
external usenet poster
 
Posts: n/a
Default 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  
Old August 4th, 2004, 01:27 PM
Mark Senibaldi
external usenet poster
 
Posts: n/a
Default 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  
Old August 5th, 2004, 01:40 AM
Ken Snell
external usenet poster
 
Posts: n/a
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 06:19 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.