Results 1 to 7 of 7
  1. #1
    daisy is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2021
    Posts
    2

    Generate Buttons based on number of entries in a table

    Hello,



    I'm pretty new to access and am still learning some of the functionality. For my project, I am keeping a record of completed courses that participants may have taken. Each course is assigned a particular category, some courses may have more than one category.

    As a loose example say course #1 is art, course #2 is writing, course #3 is math, course #4 is science, and course #5 is math AND science.

    I may need to add additional courses down the road and flag them as a category (or multiple categories). To do this, I have a form where I can enter course specific information, as well as check a box for a particular category and generate a new course record from that information.

    However, I may wish to add additional categories down the road as well. (or change them) I'd like the checkboxes on the course entry form to automatically update if the category table changes. Is there a way to loop through the category table and generate a checkbox for each category? That way if a new category is entered, the form automatically updates as well as with the proper number of categories. Currently, I have to go through and change the code or add / remove checkboxes manually. I am wondering if it is possible to automate this function.

    Any help is greatly appreciated!

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,569
    Look at how the switchboard form is populated.
    I would probably have a combo and just the one button.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,424
    If you constantly need a new control because of an added field then you have committed Excelitis and have designed your tables as you would spreadsheets. That's a big mistake that will only haunt you from here on in. If you don't know what db normalization is the research it (perhaps start with these)
    Normalization Parts I, II, III, IV, and V
    http://rogersaccessblog.blogspot.com...on-part-i.html
    and/or
    http://holowczak.com/database-normalization/

    If you do understand it and your db is normalized then I have not understood what you're doing.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    daisy is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2021
    Posts
    2
    Quote Originally Posted by Welshgasman View Post
    Look at how the switchboard form is populated.
    I would probably have a combo and just the one button.
    The problem with the combo box is that I can only select 1 category at a time. I may need to select multiple categories. Essentially, I need a combo box where each of the options inside it is toggleable. Is there a way I can select multiple entries in a combo box?
    Last edited by daisy; 06-29-2021 at 02:32 PM. Reason: added quote

  5. #5
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    It is possible to do this with a combo if you have a multivalued field but most developers will tell you that is a VERY BAD idea! See Multivalued Fields - Mendip Data Systems

    I suggest you use a multiselect listbox instead.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  6. #6
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,424
    There is also another approach which is sometimes used if selections might need to be maintained for several processes, or modified by e.g. removing one item but keeping the rest.

    Click image for larger version. 

Name:	frmDepts.jpg 
Views:	12 
Size:	13.5 KB 
ID:	45608
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Further to the suggestions/advice made so far, I recommend you write (perhaps in point form) the essence of your proposed application. Identify the things involved and what it is that relates them one to another. Understand WHAT you are dealing with before determining HOW in may be accomplished in Access.

    Make a data model that you can modify before committing to a physical database design. Test the model and adjust as necessary. See stump the model for ideas.

    Mock up some data, and test scenarios.

    I agree that 2 multiselect listboxes seem appropriate, but focus on your tables and relationships before the user interface.
    Good luck.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 12
    Last Post: 03-27-2020, 09:46 AM
  2. Replies: 8
    Last Post: 01-28-2020, 01:55 PM
  3. Limit record entries based on number in field
    By lamore48 in forum Access
    Replies: 5
    Last Post: 02-12-2018, 02:05 PM
  4. Replies: 6
    Last Post: 10-12-2017, 06:07 AM
  5. Generate Fixed Number of Entries
    By dustonabt12 in forum Reports
    Replies: 6
    Last Post: 07-10-2013, 01:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums