Putting a CheckBox next to each item in a combo box

  • Thread starter nouveauricheinvestments
  • Start date
N

nouveauricheinvestments

Is there any way to put a check box next to each item in a combo box?
I am assuming I would have to somehow do it in the query, but I'm not
sure what it would entail. The combo box is located on a form and is
used to filter a subform, the value of which is the criteria for my
query. I am using the following Union query to select the results for
the combo box and filter the subform.

SELECT Trade_Specialist, ID FROM Trade_Specialists
UNION SELECT 0, "(ALL)" FROM Trade_Specialists
ORDER BY Trade_Specialist;
 
M

Mark A. Sam

No, but you can have a boolean field value. If you are looking to check an
item as True/False from the Combo list, it can't be done in Access unless
there is a third party control which will do it. You do something like
selecting the item, then double clicking on the combo (DoubleClick event) to
change the value of the check box for the selected item. It would take some
simple coding.

God Bless,

Mark A. Sam
 
N

nouveauricheinvestments

No, but you can have a boolean field value. If you are looking to check an
item as True/False from the Combo list, it can't be done in Access unless
there is a third party control which will do it. You do something like
selecting the item, then double clicking on the combo (DoubleClick event) to
change the value of the check box for the selected item. It would take some
simple coding.

God Bless,

Mark A. Sam

How would I include the combo box? The values in the combo box might
change - some might be added, some might be removed. How would I go
about adding a checkbox (boolean field) to a query?
 
N

nouveauricheinvestments

No, but you can have a boolean field value. If you are looking to check an
item as True/False from the Combo list, it can't be done in Access unless
there is a third party control which will do it. You do something like
selecting the item, then double clicking on the combo (DoubleClick event) to
change the value of the check box for the selected item. It would take some
simple coding.

God Bless,

Mark A. Sam

How would I go about adding a checkbox like this? I am assuming I
would have to add it via the SQL statement for the combo box...not
sure how to do that...
 
M

Mark A. Sam

You need to add a boolean field to the table which the combobox is bound to.
Add it to the query grid and make sure the ColumnCount property of the
combobox accounts for it. So if the Rowsource of the combo has three
fields, Trade_Specialist, ID and the boolean field, the ColumnCount property
should be 3.

Lets say that the combobox is named cboTradeSpecialist and the boolean field
is chkMate. If you have the three fields included in the Rowsource and the
ColumnCount property is set to three then place this code in the DoubleClick
event of the combo. [chkMate] is a checkbox control on the form bound to
the field chkMate.

Private Sub cboTradeSpecialist_DblClick(Cancel As Integer)
On Error Resume Next

[chkMate] = Not [chkMate]
[cboTradeSpecialist].Requery

End Sub

This will toggle the [chkMate] field on and off.

This is untested but should work.

God Bless,

Mark A. Sam
 
N

nouveauricheinvestments

You need to add a boolean field to the table which the combobox is bound to.
Add it to the query grid and make sure the ColumnCount property of the
combobox accounts for it. So if the Rowsource of the combo has three
fields, Trade_Specialist, ID and the boolean field, the ColumnCount property
should be 3.

Lets say that the combobox is named cboTradeSpecialist and the boolean field
is chkMate. If you have the three fields included in the Rowsource and the
ColumnCount property is set to three then place this code in the DoubleClick
event of the combo. [chkMate] is a checkbox control on the form bound to
the field chkMate.

Private Sub cboTradeSpecialist_DblClick(Cancel As Integer)
On Error Resume Next

[chkMate] = Not [chkMate]
[cboTradeSpecialist].Requery

End Sub

This will toggle the [chkMate] field on and off.

This is untested but should work.

God Bless,

Mark A. Sam


How would I include the combo box? The values in the combo box might
change - some might be added, some might be removed. How would I go
about adding a checkbox (boolean field) to a query?

Okay I will reboot my computer (I'm in linux right now) and let you
know how goes. Given the fact that my combo box is the criteria for
my query, will I need to change the criteria statement? This is hwat
it says:

=[Forms]![Current Unapproved Tickets]![Combo3] OR [Forms]![Current
Unapproved Tickets]![Combo3]=0
 
N

nouveauricheinvestments

You need to add a boolean field to the table which the combobox is bound to.
Add it to the query grid and make sure the ColumnCount property of the
combobox accounts for it. So if the Rowsource of the combo has three
fields, Trade_Specialist, ID and the boolean field, the ColumnCount property
should be 3.
Lets say that the combobox is named cboTradeSpecialist and the boolean field
is chkMate. If you have the three fields included in the Rowsource and the
ColumnCount property is set to three then place this code in the DoubleClick
event of the combo. [chkMate] is a checkbox control on the form bound to
the field chkMate.
Private Sub cboTradeSpecialist_DblClick(Cancel As Integer)
On Error Resume Next
[chkMate] = Not [chkMate]
[cboTradeSpecialist].Requery
This will toggle the [chkMate] field on and off.
This is untested but should work.
God Bless,
Mark A. Sam

Okay I will reboot my computer (I'm in linux right now) and let you
know how goes. Given the fact that my combo box is the criteria for
my query, will I need to change the criteria statement? This is hwat
it says:

=[Forms]![Current Unapproved Tickets]![Combo3] OR [Forms]![Current
Unapproved Tickets]![Combo3]=0

I tried this and the boolean field is displaying as 0 or for my (ALL)
option, -1. This is the SQL statement I am using.

SELECT ID, Trade_Specialist, [Select Multiple For Subform] FROM
Trade_Specialists
UNION SELECT 0,"(ALL)",Yes FROM Trade_Specialists
ORDER BY Trade_Specialist;

Also, in the underlying query, my foreign ID field criteria is based
off of the ID field from the combo box(which you cannot see as the
width of the column is set to 0). The criteria looks like this.

[Forms]![Current Unapproved Tickets]![Combo3]

Then I have another field which you cannot see which reads the same as
above for the field and the criteria is 0.
 
M

Mark A. Sam

Okay I will reboot my computer (I'm in linux right now) and let you
know how goes. Given the fact that my combo box is the criteria for
my query, will I need to change the criteria statement? This is hwat
it says:

=[Forms]![Current Unapproved Tickets]![Combo3] OR [Forms]![Current
Unapproved Tickets]![Combo3]=0

I tried this and the boolean field is displaying as 0 or for my (ALL)
option, -1. This is the SQL statement I am using.

SELECT ID, Trade_Specialist, [Select Multiple For Subform] FROM
Trade_Specialists
UNION SELECT 0,"(ALL)",Yes FROM Trade_Specialists
ORDER BY Trade_Specialist;

Also, in the underlying query, my foreign ID field criteria is based
off of the ID field from the combo box(which you cannot see as the
width of the column is set to 0). The criteria looks like this.

[Forms]![Current Unapproved Tickets]![Combo3]

Then I have another field which you cannot see which reads the same as
above for the field and the criteria is 0.
 
M

Mark A. Sam

I guess I'm lost. I thought that you wanted to see the boolean value on the
combo list. Is [Select Multiple For Subform] the name of the field? If so
you should allow it to be display by setting the ColumnCount Property to 2
and the ColumnWidths property to 0;2;.5 or something simlar so that the
values display as you want them. The ListWidth property should equal the
sum of the ColumnWidths values. All of the values for the boolean will
initially be 0. You can set them in the table or on the form. My double
click method was just a method to do it, but you can drag it from the field
list onto the form and do it manually if you want it to show.

I don't know if I'm helping you. We seem to be addressing things from
different angles.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top