PDA

Click to See Complete Forum and Search --> : Checkboxes from database


jpierce
Jun 30th, 1999, 07:19 PM
I have a look up table in ACCESS that has about 30 records I want to be able to display all of these as related checkboxes. I was hoping there is a way to set this up from a data control instead of having to hard code or type all these out manually one at a time.
Anyone got any advice?

KentJ
Jul 5th, 1999, 09:17 PM
It is indeed unfortunate that VB6's check box control can't be bound like a textbox, or data_combo.

You're pretty much stuck setting (and reading) the check boxes in code. With a little cleverness the job can be made easier though. Organize the checkboxes into an array for example, then use a loop to populate them. Personally, I usually opt for ugly and simple rather than short and clever. I would collect the boxes into an array, enumerate named constants to use for the indices, and then in code clear all the boxes, then cut and paste 30 if statements. Something like below:

for i = 0 to 29
checkbox(i).value = FALSE
next i

if data!field1 then checkbox(field1).value = true
if data!field2 then checkbox(field2).value = true
etc

Good luck, hope this helps!