473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

checkboxes on form to run query

Need help with checkboxes on form. I have 17 categories in a table with dates in the fields. I want to have a search form with 17 checkboxes so a user can check a checkbox to get the date, or check more than one checkbox to have multiple dates for the corresponding category. for example, one category is red training, one category in blue training, one category is white training all with dates of completion. on the form I check red training and get the name of all people who completed red training and show the date, and does not show the other training, or I check red and blue training, gives me the name and the dates completed. Thanks for anybody who can help.
May 3 '16 #1
11 1428
PhilOfWalton
1,430 Expert 1GB
Probably not the neatest way of handling things. What happens when the 18th category gets added - a complete re-design.
#I would suggest a multi-select listbox based on your categories (that way the number is irrelevant)

You then build a criteria based on the ItemsSelected from your list box and apply that as a filter.

Sorry this is a bit vague, but a little more information on your table structure would help.

Phil
May 3 '16 #2
zmbd
5,501 Expert Mod 4TB
IMHO: your database could use a redesign now:
Database Normalization and Table Structures

Under normalization you most likely should have one table holding the Employee information, one table holding the category of training and a third table that relates the two tables with dates.

You can still use a multiselect List box as Phil has suggested or another approach is to use subforms, for example have a Parent, Child, Grandchild arrangement (see image here:) with the Employee at the Parent level, the Categories as the Child and Dates as the grandchild... or just parent as the Employee and the Category with dates as the Child subform. Or a multitude of other designs that in the long run would make upkeep on your data much more efficient.
May 3 '16 #3
Table Structure:
Expand|Select|Wrap|Line Numbers
  1. Name        Red Training     Blue Training    White Training
  2. Doe, John   4/4/16           3/5/16           1/9/16
I would like to let the user select one, two or all of the training categories and the query run to a report. But if the user selects Red Training, Blue and White Training doesn't show.
May 3 '16 #4
zmbd
5,501 Expert Mod 4TB
Very much a candidate for Normalization as mentioned in my last post.

We'll have to see the code you are using to create your report.
May 3 '16 #5
PhilOfWalton
1,430 Expert 1GB
Agree with zmbd.
I think you need a table of Employees, a table or Categories and a Join table with a combined key of EmployeeID and CategoryID and a CompletionDate. Whether the CompletionDate is part of the key depends on whether it is conceivable that John Doe could re-do his Red Training and have 2 different completion dates. On the assumption that this could NEVER happen, then CompletionDate is not part of the key.

Phil
May 3 '16 #6
So should I have 3 tables or two?

Table Employees
ID
LastName
FirstName

Table Categories
Red Training
Blue Training
White Training

Table Complete Date
Completion Date
May 3 '16 #7
zmbd
5,501 Expert Mod 4TB
Personally I would go with three; however, I don't know your workflow.

My design in part might be something like
(where: PK = Primary Key, FK = Forgien Key):
Expand|Select|Wrap|Line Numbers
  1. t_employee
  2. [pk_employee] autonumber
  3. [employee_Lname] shorttext(50)
  4. [employee_Fname] shorttext(50)
  5. [employee_badge] shorttext(15)
  6. [other fields and related FK]
Expand|Select|Wrap|Line Numbers
  1. t_categories 
  2. [pk_categories] autonumber
  3. [categories_name] numeric(long)
Expand|Select|Wrap|Line Numbers
  1. t_traininglog
  2. [pk_traininglog] autonumber
  3. [fk_t_employee] numeric(long) enforced relationship t_employee
  4. [fk_t_categories] numeric(long) enforced relationship t_catagories
  5. [traininglog_datecompleted] date
In t_traininglog I have not constrained the table to prevent duplicated entries ([employee],[category],[datecompleted]); however, at minimum, I would advise one to create an additional composite index to prevent duplicating the same [employee], [category],[datecompleted] record entry.... or you could create an index that prevents a duplicate of the employee, category if the employee was only required to take the training once in the service time of the employee. Of course, one can add logic to a form (and since Access2013 - table level Macros) to prevent this from happening; however, I believe that the simple composite index is sufficient, elegant, and works even when Macro/VBA is disabled.

>> Why not use these additional indexes as the primary key...
Personal choice.
I very strongly dislike composite Primary (aka Natural) keys in tables as these types of Primary Keys make establishing inter/intra-table relationships fiddly, creating select and update/append queries become needlessly complex, and last (but not least) Macros and VBA just do not handle them as gracefully as the arbitrary surrogate primary key. (also, I am in the group that holds that primary keys shouldn't normally have any "real world" meaning... there are some small exceptions such as the periodic chart of the elements, Fe, will be Iron, and Ca will be calcium :) but then again, I use the atomic number :-) )

>> Of Note: the "autonumber" datatype should NOT be relied upon for anything meaningful such as serial or sequential numbering. Autonumbers have one and only one use, to uniquely identify the record.

We're way off topic here so let's move back,

you will need some code at runtime to loop thru either the t_traininglog and the related tables or a query (either in the VBA or as an Access Object) and set your check boxes... but what happens when you add a new category, then you have to redesign the form.

A Parent/Subform arrangement might be a better choice, and most likely will not need to be redesigned every time you need to add a category.

The attached image is an example of one that is a bit more than you might need as it has a parent form and two subforms with the second subform tied to the first subform. However, once can move to the correct parent, and either select, update or enter a new child. The child record once selected will filter out the grandchildren... etc....

Using this arrangement, no code is needed to create the entries. Simply move the parent form to the correct Employee, the related training shows up in the subform, and you can make your entries there.
In the subform, use a combobox bound to [fk_t_categories] with a record source based on the t_catagories showing just the [categories_name]

May 4 '16 #8
zmbd,

Thanks, I will read this over and see what I can do. This DB I will use to track training for my company. My ultimate goal is to be able to query the records for certain training with dates. I would consider myself a beginner/intermediate at access, but I really enjoy using it, so I'm really trying to learn more and more. I'm creating several databases for my company, I just started there last November, and they have some processes that need updating. I really, really appreciate all the help.

Gary
May 4 '16 #9
PhilOfWalton
1,430 Expert 1GB
Please excuse the crudeness of these two images.
Categories.png shows my member form (equivalent to your Employee form) and my interest subform (equivalent to your Categories subform).
As you can see there is a combo box to select my interests. Your combo box would select your category.
Where I have a comment, you would have a completed date.

The Categories2.png shows the situation the other way round. In other words in my case which members have a particular interest.
So in your case, you would select a category, say White Training and it would show all those who had done the course and completion dates where applicable.

Phil

May 4 '16 #10
PhilOfWalton, could you try to send me the pics better, they are real fuzzy. I really want to use your send category you sent. Select a training and show who has taken it. Thanks for your help.
May 19 '16 #11
PhilOfWalton
1,430 Expert 1GB
Am having problems getting clearer pictures. If you let me have your email, I can send them as attachments

Phil
May 19 '16 #12

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

Similar topics

1
by: YesBalala | last post by:
I am using CGI.pm, and getting the parameters similiar to the followings, use CGI::Carp qw(fatalsToBrowser); use CGI qw(:all); : my $task = param('task'); my $username= param('username'); ...
0
by: Hi5 | last post by:
Hi, I am working for a client with loads of expectations from a simple database. Now, they want me to make them an access form, in which it will enable them to query the database using theee...
1
by: dm1608 | last post by:
Hi all -- I'm rapidly learning ASP.NET 2.0 (never really did much .NET before... mainly an ASP and PHP guy until now) and seem to be having some technical challenges that I'm hoping someone can...
2
by: jim | last post by:
I have created a Table that has 13 fields and 2 Primary Keys, e.g. 60 1, 60 2, ... 60 28, 61 1, 61 2, ... 61 28, etc... I want to create a Form where I can input the Primary Key values to query...
2
by: bindurajeesh | last post by:
I have the following in by web form code behind and it says that "operator '&' is not defined for types 'String' and 'System.Web.UI.WebControls.checkbox'. How do you pass the value of a checkbox...
3
by: sphinney | last post by:
I have a form with a subform. The code of the parent form alters the "Recordsource" property of a subform. Altering this property automatically triggers the subform to requery a table that has lots...
1
by: dohminator | last post by:
Hello Experts, I have two systems written in Access 2003 that I'm in the process of merging. A user will be given a specific screen depending on his user name. I have a form (let's call it...
8
by: glamster7 | last post by:
Ok folks its Friday & I'm feeling a bit thick (also not very well). I have a form Salonmanagerdetail wich allows the user to enter the following details Stylist_Id,Stylist_Name,Group_Name &...
1
by: mbatestblrock | last post by:
I think I have a rather advanced question that I was hoping to find some good help with. I am still pretty new to VBA and I know that doesn't help my situation here. But here is what I am trying to...
4
by: Yitzak | last post by:
Have a query that is arregated into crosstab query, it is working correctly. select Yes as selected from tblname or select true as selected from tblname Produces -1 ( vba value of True) in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.