Results 1 to 7 of 7
  1. #1
    taya621 is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Jan 2011
    Posts
    38

    Hide/Show Columns based on DropDown Selection in Form


    Hello,
    I have few fields that show up in datasheet view on a form. My first field has dropdown boxes with selections that user can choose. Based on the selection, I'd like some columns to hide or show.
    For example, if user chooses "Work Type A" from my first column, Columns H thru J will hide and therefore, only allow user to fill information in the the showing columns.
    I want to do this becaues there are a lot of work types users can be working on that each have their own set of fields to fill out so I only want the ones that apply to that work type to show.

    Thank you in advance for your help!

  2. #2
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,044
    Hi,

    I would create a templates table where you can store which columns have to be shown for which work type. Then you can use this templates table to set the ColumnHidden property of the control in the form each time another work type is chosen.
    The templates table has the advantage that whenever something changes about the columns (new columns, change in which cols have to be hidden, ...) you only have to change the data in the table and not the code.

    succes
    NG

  3. #3
    taya621 is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Jan 2011
    Posts
    38
    Hi Noella!
    So we meet again - thank you!
    I am unfamiliar with table templates...where would I go to create one? How do I make a table template instead of just a regular table?
    Thanks!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Another thought:

    http://www.baldyweb.com/ConditionalVisibility.htm

    though with a datasheet I think you have to use ColumnHidden rather than Visible. That said, the request implies a normalization problem. I'm curious what the table/field structure is.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,044
    Hi,

    a bit of a misunderstanding, it's just an ordinary table but holding all information regarding the way the columns should be shown. You can link it with a one to many relation to the WorkTypes table. In the table you can have the following fields:

    tplID ........autonumber and PK
    tplWorkType .......... FK to the worktypes table
    tplFormName ........... name of the form
    tplColumnname..............name of the column that has to be shown/hidden
    tplShow............. YES/NO field that is set to True if the column has to be shown.


    hope this clears things up

    NG

  6. #6
    taya621 is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Jan 2011
    Posts
    38
    Thank you for that. I have decided to go a slightly different route. Basically, here is what I have: I have taken a MS template for "Billible working hours" and I'm trying to change it to what I need because although I do not want to keep track of billable working hours, I need to keep track of what the employee is doing. I have various work codes which are different - unrelated - tasks that the employee does. Since these tasks are unrelated, I want them to be able to click on the work code type they are working on and then the appropriate form will show (this is where I diverged from hiding columns) then the employee will fill out the requested information, save and move on to another one of the same work code or to a different work code type. I just began so the databse has a lot of the template's things but I intend to change them to what I need. Do you think I should just start from scratch? Eventually, I need a whole series of reports to find different info of what the employee has been working on, how long it takes to do each work code, etc. My question is whether I should keep the Work Hours table and have all my info from the different work code forms go there. Or should each different work code have it's own table and its own form?...
    OR should I have not diverged, but rather, have my work hours list datasheet view form hide/show columns based on the dropdown selections?
    i just don't know where the best/most efficient place to start is.
    thank you for your help!

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I assume that's in 2010 format, as I can't open it with 2007. Generally, I'd expect to have a related table for tasks, with a record for each task performed.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Combo Box dropdown to size width of columns
    By noweyout in forum Forms
    Replies: 1
    Last Post: 02-18-2011, 05:56 AM
  2. Replies: 1
    Last Post: 11-11-2010, 11:00 AM
  3. Replies: 2
    Last Post: 08-03-2010, 10:16 AM
  4. Show/Hide Columns in a Query
    By SCFM in forum Access
    Replies: 1
    Last Post: 02-23-2010, 08:04 AM
  5. Replies: 6
    Last Post: 06-03-2009, 02:01 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