Results 1 to 7 of 7
  1. #1
    jdanieluk is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Mar 2017
    Posts
    22

    Display a different Sub-form based on a drop down box selection?

    I was wondering, is there a way to have a form, with a sub-form, that uses the selections from a drop down box to bring up different sub-forms.



    Say as an example, I have a Maintenance Form that a technician could open and select items from a drop down box for whatever they are working on. If they were doing a Oil Change they would select that item and the sub-form would change to the Oil Change Entry form. If they were doing a Brake Job they would select that item from the list and the sub-form would change to the Brake Job Form. etc etc..

    Maybe I am looking at this the wrong way?

    I was just wondering if this can be done from a drop down box.

    Any ideas are appreciated.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Sure. Presuming the combo contains actual names of subforms, set the SourceObject property of the subform control in the after update event of the combo, using the value from the combo.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    An alternate method: don't know how many sub forms you have, but you could use a tab control.......

  4. #4
    jdanieluk is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Mar 2017
    Posts
    22
    Great ideas guys. I have used the tab approach for another form, I just wanted to try out using the drop down box. Thanks for the idea on how to do that. I'm going to mess around with this a bit.

  5. #5
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    If the combo does not (cannot) contain the subform name, another way would be to write code that uses the combo value in its AfterUpdate event to set the source object property. If there are more than, say 3 or 4 possibilities, I'd probably use a Select Case block, e.g.

    Code:
    Select Case Me.cmbMyCombo
     Case "apple"
       set source to apple subform
     Case "orange"
      set source to orange subform
     Case etc.
    End Select
    I'm presuming stuff here, like you know the syntax for the subform control reference and when to use or not use quotes around the Case values.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I don't really like Navigation form but this is exactly what it accomplishes without VBA.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

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

Similar Threads

  1. Cascading Drop Downs Based on Previous Selection
    By KirstyAmanda in forum Forms
    Replies: 6
    Last Post: 05-05-2017, 07:13 AM
  2. Auto text based on drop menu selection
    By mandykoonts in forum Forms
    Replies: 6
    Last Post: 01-06-2014, 04:17 PM
  3. Replies: 8
    Last Post: 12-07-2013, 05:22 PM
  4. Replies: 2
    Last Post: 08-14-2013, 04:29 PM
  5. Display image based on combobox selection?
    By 10 Gauge in forum Forms
    Replies: 2
    Last Post: 09-15-2011, 07:42 AM

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