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

multiple checkbox in access

P: 92
Hi
I have a form that there is 3 checkbox in it.
one or two or all 3 can be selected.
i want to pass the selected check box to the sql table.
the problemis when I just choose 1 checkbox then it doesnt go.

if i just choose year0 then it wont pass

'year0
If chk_year0 = True And chk_year1 = False And chk_year_2 = False Then
rst.Fields("target_spb_year_list") = year0.Caption
End If


but if i chose year0 and year1 then it will pass.

'year 0 and year 1
If chk_year0 = True And chk_year1 = True And chk_year_2 = False Then
rst.Fields("target_spb_year_list") = year0.Caption & " " & year1.Caption
End If



i would apprecaite any help,

thanks
Jul 29 '09 #1
Share this Question
Share on Google+
3 Replies


puppydogbuddy
Expert 100+
P: 1,923
Try it this way:
'year0
If chk_year0 = -1 And nz(chk_year1,0) = 0 And nz(chk_year_2,0) = 0 Then
rst.Fields("target_spb_year_list") = year0.Caption
End If

False does not get checked, so it is returning a null. Using the null to zero function converts the nulls to zero with zero being false.
Aug 1 '09 #2

P: 74
I didnt think that check boxes could contain null data. I thought that they were either true or false, but never null. Can you chek them independantly?
Expand|Select|Wrap|Line Numbers
  1. If [chk_year0]= True Then
  2. If [ck_year1] = False Then
  3. If [chk_year_2] = False Then
  4. blah blah blah
  5. End If
  6. End If
  7. End If
  8.  
By the way, are the underscores "_" actually in the field name, or are they spaces. I dont know why (probably got treated as a math problem) but when i used a field that was HL2 it wouldnt cooperate properly until I put the brackets "[]" around it (although it was a number field....that was probably why, probably wont affect a yes/no field). If they are spaces, i would put the brakcets around them and use spaces instead of the underscore, just because that is how they were actually written, although someone here might say "they work either way" I just dont like numbers at the end of my field names or the underscores.
Aug 4 '09 #3

Post your reply

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