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

Returning True/False records from a table using VB

P: 32
Good afternoon,

Can someone please guide me towards how to return records from a table. I currently have a table with about 21 fields, and 21 records. I have one field that is just text and the remaining fields are checkboxes, which allows the user to select true/false for each record in the text field.

I.E.
Expand|Select|Wrap|Line Numbers
  1. Field Txt       Chkbx1 chkbx2 chkbox3
  2. Eat Apples    True     False        True
Now, how to I loop through this table, for each "FieldTxt" returning only the true values, and then moving on to the next.

This will eventually allow me to have a table that allows the user to select specific charts (via. the checkboxes) they would like to print out, for each record entered in the table.

I would greatly appreciate any help can be offered.
Feb 7 '07 #1
Share this Question
Share on Google+
11 Replies


Rabbit
Expert Mod 10K+
P: 12,349
Do you mean returning the records where chkbox1 is true regardless of the others, chkbox2 is true, or Chkbox3 is true depending on which check box field the user wanted to see?
Feb 7 '07 #2

nico5038
Expert 2.5K+
P: 3,072
Your table design isn't normalized, giving this trouble.
You would need for every row 21 rows for the same text.
I guess it's a kind of multiple choice and you would need three fields:
1) Text
2) Option
3) YesNo
Now you'll probably have Option1 being True or False
Now you'll probably have Option2 being True or False, etc.

Such a table can be filtered instantly by checking the YesNo field for being True.

Now you would need to normalize the table like:

select Text, "01" as Origin, Check01 from tblX where Check01=True
UNION
select Text, "02" as Origin, Check01 from tblX where Check02=True
...etc,till
select Text, "21" as Origin, Check21 from tblX where Check21=True;

That UNION can then be used in a new query for filtering the True Check01 from the UNION query.

Nic;o)
Feb 7 '07 #3

P: 32
Thank you for your response,

I am not clear on what you mean by my table design not being normailzed?
Should I have this checkbox table in a form instead, and then have the information passed to a table??




Your table design isn't normalized, giving this trouble.
You would need for every row 21 rows for the same text.
I guess it's a kind of multiple choice and you would need three fields:
1) Text
2) Option
3) YesNo
Now you'll probably have Option1 being True or False
Now you'll probably have Option2 being True or False, etc.

Such a table can be filtered instantly by checking the YesNo field for being True.

Now you would need to normalize the table like:

select Text, "01" as Origin, Check01 from tblX where Check01=True
UNION
select Text, "02" as Origin, Check01 from tblX where Check02=True
...etc,till
select Text, "21" as Origin, Check21 from tblX where Check21=True;

That UNION can then be used in a new query for filtering the True Check01 from the UNION query.

Nic;o)
Feb 8 '07 #4

Rabbit
Expert Mod 10K+
P: 12,349
This tutorial will teach you about Normalization: Normalisation and Table structures

I should probably read it myself so I know what everyone's talking about when they say normalization.
Feb 8 '07 #5

NeoPa
Expert Mod 15k+
P: 31,347
Thank you for your response,

I am not clear on what you mean by my table design not being normailzed?
Should I have this checkbox table in a form instead, and then have the information passed to a table??
If I understand correctly, Nico is saying your data should be stored as :
Expand|Select|Wrap|Line Numbers
  1. Text           Option    YesNo
  2. Eat Apples     ChkBx1    True
  3. Eat Apples     ChkBx2    False
  4. Eat Apples     ChkBx3    True
This may seem strange to someone not used to it, but it is a design that provides very high levels of flexibility of use of your data when used with SQL.

Maybe we can help more with a clearer understanding of your problem. I found I understood some of the problem but it wasn't clear to me what you're actually after.

PS. Rabbit, YES, go off and read it immediately. I'll be testing you later ;) I expect you know most of it already mind. I found it helped crystalise my understanding. I'd certainly recommend it.
Feb 9 '07 #6

P: 32
If I understand correctly, Nico is saying your data should be stored as :
Expand|Select|Wrap|Line Numbers
  1. Text           Option    YesNo
  2. Eat Apples     ChkBx1    True
  3. Eat Apples     ChkBx2    False
  4. Eat Apples     ChkBx3    True
This may seem strange to someone not used to it, but it is a design that provides very high levels of flexibility of use of your data when used with SQL.

Maybe we can help more with a clearer understanding of your problem. I found I understood some of the problem but it wasn't clear to me what you're actually after.
ok the problem with having it this procedure, using the previous example. is that there are going to be 21 check boxes for Eat Apples. Now I have 20 other items, (ie. Eat Oranges, Eat Pears, etc) that are going to require another 21 checkboxes.
The person who will end up using this tool will have to scroll through tons of data just to check off a few boxes. Is there anyway to make this process less tedious using normalization?
Feb 9 '07 #7

Rabbit
Expert Mod 10K+
P: 12,349
Ultimately, in the end, I am unsure what you are asking for.
I read your post but I see too much ambiguity about the results you want.
Feb 9 '07 #8

NeoPa
Expert Mod 15k+
P: 31,347
ok the problem with having it this procedure, using the previous example. is that there are going to be 21 check boxes for Eat Apples. Now I have 20 other items, (ie. Eat Oranges, Eat Pears, etc) that are going to require another 21 checkboxes.
The person who will end up using this tool will have to scroll through tons of data just to check off a few boxes. Is there anyway to make this process less tedious using normalization?
In answer to this (specific) question - Yes. Queries can be built to show this data in a number of ways.
Going back to your original question though (which also pertains to this somewhat), as we have a very poor idea of what you have and what you want, it's hard to know what to suggest for you.

One fundamental question for you (don't take this to mean that the whole question is clear just by answering this mind you) - Is there any relation between the 21 options and the 21 records? Or is that merely a coincindence?
Feb 9 '07 #9

P: 32
In answer to this (specific) question - Yes. Queries can be built to show this data in a number of ways.
Going back to your original question though (which also pertains to this somewhat), as we have a very poor idea of what you have and what you want, it's hard to know what to suggest for you.

One fundamental question for you (don't take this to mean that the whole question is clear just by answering this mind you) - Is there any relation between the 21 options and the 21 records? Or is that merely a coincindence?

Right now there is no relationship established.
Feb 10 '07 #10

Rabbit
Expert Mod 10K+
P: 12,349
Can you provide an example of the results you're looking for? I'm uncertain of what it is that you're looking for.
Feb 13 '07 #11

NeoPa
Expert Mod 15k+
P: 31,347
Right now there is no relationship established.
The question is about a relation, not a relationship.
A Relationship would be a fundamental part of Access (linking tables) but a relation could be something a lot simpler. IE Records related that all have names starting with the same letter.
Please feel free to answer this question (as well as a number of others in your thread) or not. We have no axe to grind, we will simply be unable to help you much without it.
Feb 13 '07 #12

Post your reply

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