ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   List Box Forms (https://www.excelbanter.com/excel-discussion-misc-queries/103747-list-box-forms.html)

Nimish

List Box Forms
 
I havea form that I have created with two list boxes. The macros
launches a filter. How do I create a property in the list box that
would allow a user to "deselect" the list box. Right now, once the
user clicks in the box, a name is highlighted and the only option is
the select another name. You can't click on a name again and deselect
it.

My code is:

Private Sub CommandButton1_Click()
vEmpSups = frmSupervisors.lstEmpSups.Value
vRoutesups = frmSupervisors.LstRouteSups.Value

Sheets("DispatchSheet").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:=vEmpSups
Selection.AutoFilter Field:=2, Criteria1:=vRoutesups

End Sub


Harald Staff

List Box Forms
 
Hi

Something like

Private Sub BtnDeselect_Click()
frmSupervisors.lstEmpSups.Listindex = -1
End Sub

HTH. Best wishes Harald

"Nimish" skrev i melding
ps.com...
I havea form that I have created with two list boxes. The macros
launches a filter. How do I create a property in the list box that
would allow a user to "deselect" the list box. Right now, once the
user clicks in the box, a name is highlighted and the only option is
the select another name. You can't click on a name again and deselect
it.

My code is:

Private Sub CommandButton1_Click()
vEmpSups = frmSupervisors.lstEmpSups.Value
vRoutesups = frmSupervisors.LstRouteSups.Value

Sheets("DispatchSheet").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:=vEmpSups
Selection.AutoFilter Field:=2, Criteria1:=vRoutesups

End Sub




Nimish

List Box Forms
 
Where would I place that sub....in my forms macro? How does it fit in
with the coding?

Thanks


Harald Staff wrote:
Hi

Something like

Private Sub BtnDeselect_Click()
frmSupervisors.lstEmpSups.Listindex = -1
End Sub

HTH. Best wishes Harald

"Nimish" skrev i melding
ps.com...
I havea form that I have created with two list boxes. The macros
launches a filter. How do I create a property in the list box that
would allow a user to "deselect" the list box. Right now, once the
user clicks in the box, a name is highlighted and the only option is
the select another name. You can't click on a name again and deselect
it.

My code is:

Private Sub CommandButton1_Click()
vEmpSups = frmSupervisors.lstEmpSups.Value
vRoutesups = frmSupervisors.LstRouteSups.Value

Sheets("DispatchSheet").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:=vEmpSups
Selection.AutoFilter Field:=2, Criteria1:=vRoutesups

End Sub



Harald Staff

List Box Forms
 
That would depend on how and when you want this deselection to happen. But
if it's a "deselect" commandbutton on the form, then it goes inside that
one's click event.

Your provided code is a little confusing. If Private Sub
CommandButton1_Click() is inside ther form's own module then you should
address its controls with Me instead of the form's name. Not

vEmpSups = frmSupervisors.lstEmpSups.Value
vRoutesups = frmSupervisors.LstRouteSups.Value

but

vEmpSups = Me.lstEmpSups.Value
vRoutesups = Me.LstRouteSups.Value

Same goes for the code I wrote you.

HTH. Best wishes Harald

"Nimish" skrev i melding
oups.com...
Where would I place that sub....in my forms macro? How does it fit in
with the coding?

Thanks


Harald Staff wrote:
Hi

Something like

Private Sub BtnDeselect_Click()
frmSupervisors.lstEmpSups.Listindex = -1
End Sub

HTH. Best wishes Harald

"Nimish" skrev i melding
ps.com...
I havea form that I have created with two list boxes. The macros
launches a filter. How do I create a property in the list box that
would allow a user to "deselect" the list box. Right now, once the
user clicks in the box, a name is highlighted and the only option is
the select another name. You can't click on a name again and deselect
it.

My code is:

Private Sub CommandButton1_Click()
vEmpSups = frmSupervisors.lstEmpSups.Value
vRoutesups = frmSupervisors.LstRouteSups.Value

Sheets("DispatchSheet").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:=vEmpSups
Selection.AutoFilter Field:=2, Criteria1:=vRoutesups

End Sub






All times are GMT +1. The time now is 08:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com