Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Have form create custom table based on boxes checked

Status
Not open for further replies.

clickster

MIS
Feb 19, 2002
89
US
I should probably start off by saying that I don't know VBA yet (but will be learning soon) and I'm not great with SQL, but I can usually find my way along with it. The easiest way for me to understand things is with generalities such as "first, create a make-table query...then...", but any help at all would be appreciated. Here is what I would like my form to look like:

A date box at the top (will be the table's primary key)
A list of 65 peoples' names going down and 20 check boxes going across, each representing a food item.

Each day, I need to find out what each person wants to eat that day. Some people will have nothing checked, the vast majority will have one item checked, and a few each day (5-10) will have 2-3 checked. Now if I could simply make a field for each option I would love it, but that would be 1301 fields. Instead, I need to find a way to end up with a table that only keeps track of checked boxes. The boxes will be named JohnCorn, JohnPotatoes, etc. on John's choices and SophiaCorn, SophiaPotatoes, etc. on Sophia's choices and so on. Every checkbox will be uniquely identified to a person and food. All I need the records in the table to have is the day's date followed by each item that was checked (johncorn, sophiapotatoes, etc.), one per field. The fields don't have to line up day by day or anything. The table field names can be named 1, 2, 3, etc. and it won't matter. I'll simply be querying for things such as every instance of johnpotatoes and will simply be looking for the dates that johnpotatoes occurred.

Is this ever possible or can someone suggest a better solution that would be manageable for a beginning-intermediate access user who doesn't yet know VBA?
 
Let me say it appears the way you want to store data makes sense but the form design using the check boxes does not make a lot of sense

I would suggest a combo box to select the name then a multi select listbox for their food choices

Then code something like this to fill the table

Dim varitem as variant, Strsql as string

For each varitem in list1.itemselected
Strsql = “Insert into table1 (seldate, txname,txitemid) values (‘ & date & “’,” & combo1 & “’,’” list1.itemdata(varitem) & ”’”
Currentdb.execute strsql
next

will need to clean up but hopefully you get the idea
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top