# 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;checkboxvalue3;checkboxvalue4 etc...
How can I do that?
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
By concatenating the values together when saving.

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Commented:
To avoid parsing you can use BITWISE logic to combine and separate multiple integer values in one field
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, 1, 0)
x = x Or IIf(checkboxvalue2.Checked, 2, 0)
x = x Or IIf(checkboxvalue3.Checked, 4, 0)
.....
x = x Or IIf(checkboxvalueN.Checked, 2^N, 0)
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
....
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.