By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,395 Members | 1,552 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,395 IT Pros & Developers. It's quick & easy.

Is it possible to add checkboxes inside a list box?

P: 48
Hello,

Is it possible to add checkboxes inside a list box?

Scrolling down the items will scroll down the checkboxes as well.
I can't add directly the checkbox inside the list box using the editor. :(
Aug 18 '08 #1
Share this Question
Share on Google+
11 Replies


Expert Mod 2.5K+
P: 2,545
Hi, and Welcome to Bytes!

It is not possible to customise controls in the way you suggest; in common with all such controls, a listbox control has no facilities to change one of its list components to display a checkbox control (or any other component) within it. In other words, controls do not in general nest within controls (except where especially built for that purpose, such as a tab control).

What is it you are trying to do?

-Stewart
Aug 18 '08 #2

P: 48
Hi. It is not possible to customise controls in this way; in common with all such controls, a listbox control has no facilities to change one of its list components to display a checkbox control (or any other component) within it. In other words, controls do not in general nest within controls (except where especially built for that purpose, such as a tab control).

What is it you are trying to do?

-Stewart
Thanks for your reply, Stewart.

That's a bad news for me.
But I know there's another way.

What I really wanna do is to display the list of items with checkbox per item.
If there are many items, the whole screen would need to be scrolled.

I just want the items with checkbox to be scrolled.
That way, the size of the form is maintained.

Is there a way to do this?
Aug 18 '08 #3

Expert Mod 2.5K+
P: 2,545
Hi. To some extent it is possible to mimic the effects of a listbox by designing a custom continuous form as a pop-up triggered by a custom button on another form. You can then use textboxes, checkboxes and so on as you want for each row. The recordsource for the custom form would be a query such as you would use to fill the listbox.

You would be scrolling all records, not just those with checkboxes (I can think of no way to selectively scroll part of a form only).

I use combo boxes to store the custom form selection, with a button overlaid on top of the usual arrow on the combo box to trigger a custom form. Screenshot attached (from a risk assessment application) shows the combobox/button combination (on left) and the pop-up form (the form called Severity shown).

This is just one way to produce custom forms; no doubt there are many others.

-Stewart
Attached Images
File Type: jpg ScreenHunter_24.jpg (36.6 KB, 1640 views)
Aug 18 '08 #4

P: 48
Hi. To some extent it is possible to mimic the effects of a listbox by designing a custom continuous form as a pop-up triggered by a custom button on another form. You can then use textboxes, checkboxes and so on as you want for each row. The recordsource for the custom form would be a query such as you would use to fill the listbox.

You would be scrolling all records, not just those with checkboxes (I can think of no way to selectively scroll part of a form only).

I use combo boxes to store the custom form selection, with a button overlaid on top of the usual arrow on the combo box to trigger a custom form. Screenshot attached (from a risk assessment application) shows the combobox/button combination (on left) and the pop-up form (the form called Severity shown).

This is just one way to produce custom forms; no doubt there are many others.

-Stewart
That's a good one.

Instead of making a popup form,
how about adding Subform in a Main form?

It is possible to scroll the items inside the Subform
while viewing it in the Main form.

What I couldn't do now is programmatically adding checkbox
in the Subform without closing the Main form.

Here's my code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAddUpdate_Click()
  2.  
  3.     DoCmd.OpenForm "frmUpdateListItems", acDesign
  4.  
  5.     Dim ctrl As Control
  6.  
  7.     Set ctrl = CreateControl("frmUpdateListItems", acCheckBox, acDetail, "", "", 1000, 1000)
  8.  
  9.     DoCmd.Close acForm, "frmUpdateListItems", acSaveYes
  10.  
  11. End Sub
I researched a while ago and found this.

This command is in the Main form.
The Subform is frmUpdateListItems.
Everytime I click the command button,
it created the checkbox control but
it closes the Main form.

How can I stop it from closing the Main form?
Aug 18 '08 #5

P: 48
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAddUpdate_Click()
  2.  
  3.     DoCmd.OpenForm "frmUpdateListItems", acDesign
  4.  
  5.     Dim ctrl As Control
  6.  
  7.     Set ctrl = CreateControl("frmUpdateListItems", acCheckBox, acDetail, "", "", 1000, 1000)
  8.  
  9.     DoCmd.OpenForm "frmUpdateListItems", acNormal
  10.  
  11. End Sub
  12.  
I managed to modify the code in order not to close the Main form.

I changed:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.Close acForm, "frmUpdateListItems", acSaveYes
into
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "frmUpdateListItems", acNormal
That way, it opens the Main form again as well as the updated Subform.

Dunno if this is good to implement.
But I'm still open for comments and suggestions.

Now, I'm currently using this one.
Hope I'm not wrong with this.
Aug 18 '08 #6

Expert Mod 2.5K+
P: 2,545
I'm glad you've found a solution that works for you. I am not at all sure why you need to add a checkbox dynamically, though - what is it that differentiates each row so that some need this functionality while others don't? What are you doing with the checkboxes that needs an interactive control and not just a graphic character, for instance?

I am assuming that you actually need users to be able to tick or untick the control interactively. If you don't need this functionality you are causing yourself an awful lot of work...

-Stewart
Aug 18 '08 #7

P: 48
I'm glad you've found a solution that works for you. I am not at all sure why you need to add a checkbox dynamically, though - what is it that differentiates each row so that some need this functionality while others don't? What are you doing with the checkboxes that needs an interactive control and not just a graphic character, for instance?

I am assuming that you actually need users to be able to tick or untick the control interactively. If you don't need this functionality you are causing yourself an awful lot of work...

-Stewart
Yeah, sounds like an awful work indeed.
People here are making my life miserable. lolz

But there's nothing I can do but follow what they want.
They're not programmers, that's why they sometimes
don't understand what "hard work" means in programming.

This is the logic.
When the Main form is loaded, data from a pre-determined folder are collected
and displayed in a list with checkboxes (that's in the Subform).
The Main form has a browse button. When I click an "Add" button,
the browsed data will be added to the list in the Subform.

There's a possibility that lots of data will be added in the list,
that's why I needed the scroll-feature for the list.

If there's no scroll-feature, it should be done in a lightning speed. lolz

By the way, the checkbox is used for updating the Access DB.
Aug 18 '08 #8

100+
P: 152
gpl
Yeah, sounds like an awful work indeed.
People here are making my life miserable. lolz

But there's nothing I can do but follow what they want.
They're not programmers, that's why they sometimes
don't understand what "hard work" means in programming.

This is the logic.
When the Main form is loaded, data from a pre-determined folder are collected
and displayed in a list with checkboxes (that's in the Subform).
The Main form has a browse button. When I click an "Add" button,
the browsed data will be added to the list in the Subform.

There's a possibility that lots of data will be added in the list,
that's why I needed the scroll-feature for the list.

Graham

If there's no scroll-feature, it should be done in a lightning speed. lolz

By the way, the checkbox is used for updating the Access DB.
Have you checked out the Microsoft Forms 2.0 library, this has a nice checkbox list .... if you do not have Microsoft Office, you can still get the library, this can be found in the ActivX Control Pad, freely downloadable from Microsoft - http://msdn2.microsoft.com/en-us/library/ms968493.aspx

But check the licence conditions on its use
Aug 18 '08 #9

P: 48
Have you checked out the Microsoft Forms 2.0 library, this has a nice checkbox list .... if you do not have Microsoft Office, you can still get the library, this can be found in the ActivX Control Pad, freely downloadable from Microsoft - http://msdn2.microsoft.com/en-us/library/ms968493.aspx

But check the licence conditions on its use
Nope, I haven't. I would be very nice to know this checkbox list.
I have Microsoft Office. I am using MS Office Access 2003.

Can you please elaborate on how to add this checkbox list control in the form?
Aug 19 '08 #10

100+
P: 152
gpl
Nope, I haven't. I would be very nice to know this checkbox list.
I have Microsoft Office. I am using MS Office Access 2003.

Can you please elaborate on how to add this checkbox list control in the form?
I dont have access to a developer version of Access right now, as I remember, in the toolbox, there is a 'more' option at the bottom, this gives you a long list of controls, the one you want is called something like ms forms 2.0 listbox, you will have to scroll quite a way until it appears
Graham
Aug 19 '08 #11

FishVal
Expert 2.5K+
P: 2,653
Hello, all.

ListView control with checkboxes feature is a part of "Microsoft Windows Common Controls" (I have 6.0 (SP6) version) library - MSComCtlLib (...\WINDOWS\system32\MSCOMCTL.OCX.
In Access controls menu it appears as "Microsoft ListView Control".

MSForms library has ListBox control too, but to the best of my knowledge no checkboxes are available there.

You should take into account that it couldn't be linked to query/table dataset, you will have to design code to populate it.

Regards,
Fish
Aug 19 '08 #12

Post your reply

Sign in to post your reply or Sign up for a free account.