472,133 Members | 1,162 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,133 software developers and data experts.

Listbox with checkbox displayed

Hello;

I am creating a multiselect listbox and I would like to use checkboxes
to indicate which items are selected (rather than the default highlighting.)
I would then place these selected items in a table.

I would also like to have the ability to "select all" and "deselect all".

Any help on accomplishing the above would be greatly appreciated. Thanks;

Thomas
Nov 13 '05 #1
4 14229
Thomas,

You would be better served to use a pop-up continuous form rather than a
listbox. Add a field called Selected to your table and make it Yes/No. Include
Selected on your form and it will appear as a checkbox. For "select all" and
"deselect all", you can add a button to your form that executes an update query
that sets Selected to True for all records for "select all" and to False for all
records for "deselect all". To execute your code for the selected items, you can
add a button that executes the code for all records where Selected is True. For
this you can use a query and set the criteria for Selected to True. At the end
of this code you will want to reset Selected for all records back to False so
you again use an Update query.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

"Thomas" <no*@home.com> wrote in message
news:MT******************@nnrp1.uunet.ca...
Hello;

I am creating a multiselect listbox and I would like to use checkboxes
to indicate which items are selected (rather than the default highlighting.)
I would then place these selected items in a table.

I would also like to have the ability to "select all" and "deselect all".

Any help on accomplishing the above would be greatly appreciated. Thanks;

Thomas

Nov 13 '05 #2
Hi;

Thanks for the suggestions; however, I'm not sure if that solution will
work for me. I should put the problem in context:

In the simplest terms, I have a table containing players and another
containing games. I would like track which players attended which games.

I thought this could be best accomplished by having a multiselect list
of players whereby I could select the players for a particular game and
using an action button, have the selected players saved in a table
(gameDetails).

Note that this is the simplistic presentation of what I am trying to
accomplish - it will encompass many teams and players and I will have to
derive trends and calculations from games played over the course of a
season.

I will end up tracking many different types of stats other than
attendence, but establishing which players were at any given game seems like
a fundamental first step.

Cheers;

Thomas

"PC Datasheet" <no****@nospam.spam> wrote in message
news:Wn***********@newsread2.news.atl.earthlink.ne t...
Thomas,

You would be better served to use a pop-up continuous form rather than a
listbox. Add a field called Selected to your table and make it Yes/No. Include Selected on your form and it will appear as a checkbox. For "select all" and "deselect all", you can add a button to your form that executes an update query that sets Selected to True for all records for "select all" and to False for all records for "deselect all". To execute your code for the selected items, you can add a button that executes the code for all records where Selected is True. For this you can use a query and set the criteria for Selected to True. At the end of this code you will want to reset Selected for all records back to False so you again use an Update query.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

"Thomas" <no*@home.com> wrote in message
news:MT******************@nnrp1.uunet.ca...
Hello;

I am creating a multiselect listbox and I would like to use checkboxes to indicate which items are selected (rather than the default highlighting.) I would then place these selected items in a table.

I would also like to have the ability to "select all" and "deselect all".
Any help on accomplishing the above would be greatly appreciated. Thanks;
Thomas


Nov 13 '05 #3
> I am creating a multiselect listbox and I would like to use checkboxes
to indicate which items are selected (rather than the default highlighting.) I would then place these selected items in a table.


I'd suggest using two list boxes side by side with command buttons in
between the two list boxes (Select All, Select None, >>, <<) to add or
remove selected records from one listbox to another. You'll need to set up
some queries/code so the list boxes reflect the selections requested. I've
done this on occasion and it works pretty nicely. Here's some (incomplete)
pseudo code that may give you an idea of how to do this:

Private Sub cmdAddSomething_Click()
If IsNull(Me!lstSomething) Then
MsgBox "Please select an available something.", vbExclamation, "
Nothing Selected"
Exit Sub
End If
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblSomething SET tblSomething.Select = -1
WHERE ((tblSomething.Record_ID)=Forms!frmSomething!lstSo mething);"
DoCmd.SetWarnings True
Me!lstSomething.RowSource = "qrySomething"
End Sub
Nov 13 '05 #4
Thanks - I ended up implementing something similar but your example allowed
me to clean it up.

Thomas

"deko" <no****@hotmail.com> wrote in message
news:cF*******************@newssvr29.news.prodigy. com...
I am creating a multiselect listbox and I would like to use checkboxes to indicate which items are selected (rather than the default highlighting.)
I would then place these selected items in a table.


I'd suggest using two list boxes side by side with command buttons in
between the two list boxes (Select All, Select None, >>, <<) to add or
remove selected records from one listbox to another. You'll need to set up
some queries/code so the list boxes reflect the selections requested.

I've done this on occasion and it works pretty nicely. Here's some (incomplete) pseudo code that may give you an idea of how to do this:

Private Sub cmdAddSomething_Click()
If IsNull(Me!lstSomething) Then
MsgBox "Please select an available something.", vbExclamation, "
Nothing Selected"
Exit Sub
End If
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblSomething SET tblSomething.Select = -1
WHERE ((tblSomething.Record_ID)=Forms!frmSomething!lstSo mething);"
DoCmd.SetWarnings True
Me!lstSomething.RowSource = "qrySomething"
End Sub

Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Colleyville Alan | last post: by
2 posts views Thread by John R. | last post: by
2 posts views Thread by Edmilson | last post: by
6 posts views Thread by segue | last post: by
3 posts views Thread by Ali Chambers | last post: by
1 post views Thread by John | last post: by
1 post views Thread by pradeep | last post: by
8 posts views Thread by PeteOlcott | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.