angel7170
asked on
Save Multiple Checkbox values to MS Access table
Hello,
I have a windows form created using Visual Basic where there is a multiple checkboxes applied. I want to be able to select multiple values and save them in one column in the table. I would like the format saved as
checkboxvalue1;checkboxval ue3;checkb oxvalue4 etc...
How can I do that?
I have a windows form created using Visual Basic where there is a multiple checkboxes applied. I want to be able to select multiple values and save them in one column in the table. I would like the format saved as
checkboxvalue1;checkboxval
How can I do that?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
for example :
'this code will set the value in variable x from the checkbox selection
Dim x As Integer
x = x Or IIf(checkboxvalue1.Checked
x = x Or IIf(checkboxvalue2.Checked
x = x Or IIf(checkboxvalue3.Checked
.....
x = x Or IIf(checkboxvalueN.Checked
MsgBox(x)
' this part will restore checkbox values from value in x
checkboxvalue1.Checked= ( x And 1 = 1)
checkboxvalue2.Checked= ( x And 2 = 2)
checkboxvalue4.Checked= ( x And 4 = 4)
the values you can use are 2^n
for example
2^0=1
2^1=2
2^2=4
2^3=8
2^4=16
2^5=32
....