Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Muliplt select list box - Options

Status
Not open for further replies.

mrathi

Technical User
Oct 27, 2003
115
US
First of all thanks to all the "gurus" here. I mean it.

I was wondering what all options I can have with a list box. For example, say I have a list box that lists different reports based on a query. Currently, I don't have it multiple selections. The list box just describes the various reports and I have a button that will print the selected report. I also have a button that will view the selected report.

My concern:
If I make the list box multiple select, the print button will print all the selected reports. However, I want it such that if I want to preview a certain report with the view button, it should work like the list box is not multi select. Is it POSSIBLE?
Also, if the items selected in the list box are more than one, can I disable some other buttons? If so how?

I would appreciate any help. Thanks again to all the experts.
 
The problem you will need to over come with the View Button is that the Mulit Select property can only be set in Form Design View so once you are running the form it would probably be very clunky to try and change the Multi Select setting.
To accomplish the second question, about turning off buttons you can use this

Dim ctl as Control
Dim varItm
Dim i as Integer
Set ctl = Me.ListBoxName
For Each varItm in ctl.ItemsSelected
i = i+1
If i > 1 Then
Me.Command5.Enabled = False
Else
Me.Command5.Enabled = True
End If
Next

You can add all the command buttons you want and if you add or subtract from the list, the button will be enabled anytime the selected values is 1.

Paul
 
Thanks for your reply, however, where should I put this code? I have like four buttons on the form and corresponding four "sub" in the code. So, where should I put this code?
Thanks again. By the way, for the first part of the question above, I check to see if it selects more than one, if it does and if it clicks the view button, then I give them a pop up box saying that they can select only one item for this button.
 
Sorry, this code would go in the After Update event for the List box. That way any time you make a selection in the list box, it will recalculate i and either enable or disable the command buttons. You can add all the Command buttons to the code that you want. Just list them in the If..Then portion of the code.

Paul
 
Thank you so much. You guys are just so GREAT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top