Results 1 to 13 of 13
  1. #1
    stephanie77 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2016
    Posts
    14

    Angry Subform depending on a combo box selection but...

    Hi !

    I have two different tabbed-subforms that can show up in my main form, depending on a combo box selection - that's meant for the data entry, you only get the subform needed for the option selected and it works great.

    My problem: when I go back to read previous entries, the selection has already been done so the subform is not loading anymore (access isn't the problem, it's logical, my code is in the "afterUpdate" combox box!!), unless I reselect the same option in the combo box. We can only see the selection that was done during the data entry.

    I'm a newbie ; I know how to OnLoad requery a subform but really have no idea how to refresh a subform based on an already-done combo box selection

    If someone could please help me! I would appreciate!



    Thanks in advance

  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,518
    Try the same code in the main form's current event, which fires when you change records.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    stephanie77 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2016
    Posts
    14

    Unhappy

    it invalidates completly my initial code, the subform don't show up at all anymore when try this modification

    In case it helps the combo box code is this:
    Private Sub CboChassisType_AfterUpdate()
    Select Case Me.CboChassisType.Value

    Case Is = 1
    Tab_DieselMajComponents.Visible = True
    Tab_ElectMajComponents.Visible = False


    Case Is = 2

    Tab_DieselMajComponents.Visible = False
    Tab_ElectMajComponents.Visible = True

    End Select
    End Sub

  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,518
    Should work fine, though you may need to account for the combo being null. Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    stephanie77 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2016
    Posts
    14
    Click image for larger version. 

Name:	Openingform.png 
Views:	13 
Size:	100.2 KB 
ID:	27163Click image for larger version. 

Name:	ShouldShow.png 
Views:	13 
Size:	109.0 KB 
ID:	27164Click image for larger version. 

Name:	2nd-Option.png 
Views:	13 
Size:	84.6 KB 
ID:	27162
    the DB is 10 MB and of course, don't know if and how I could export partially this darn database but I've tried to make some print screen ...

  6. #6
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    After the selection,
    - store that value in a hidden (if preferred) form textbox and link the subform on that
    - or store the name of the subform in it that should be shown if you already have a parent/child relationship established.
    On the appropriate event (Activate?) code so that whichever of the two methods is used will show the correct subform and hide the other.
    Not sure which you should do (or both) without a better understanding of how the form/subforms are linked.

    P.S. object names should never start with a number, or contain special characters (save the underscore) or contain spaces.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    stephanie77 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2016
    Posts
    14
    Both tab forms (diesel and electric) are set as "not visible" in parameters

    All subforms in every tab have their Master-Child defined (Master being "idVehicle")

    I will read again and try your propositions tomorrow and let you know! (my brain is definitely out of order it's too late !)



    P.S. As for the numbers.. Yeah... I realized that when I tried to put this combo box code actually... but the DB for a newbie like me is so big, I needed a way to quickly see my primary forms and that's the only way I found.. will have to rename once the biggest part of conception will be completed but thanks for warning me !

  8. #8
    stephanie77 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2016
    Posts
    14
    Hm that's really the only way we can somewhat refresh the damn subform? So, in a way, that combo box selection is complicating my life and I have to find a way to by-pass it?

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Can you attach the db here? I'd expect the current event to work.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    In answer to your PM, yes I meant to add code to the current event, leaving the code in the after update event. The latter handles changing the combo, the former handles changing records. If compacting and then zipping doesn't allow you to attach it here, you can email it to me.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    stephanie77 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2016
    Posts
    14
    Ok let me try to add (without removing from the other location) ! I'll tell you ! Stay tuned !

  12. #12
    stephanie77 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2016
    Posts
    14
    Working !!! Geez ! thanks a lot pbaldy!

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help!
    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. Replies: 7
    Last Post: 03-30-2015, 10:04 AM
  2. Replies: 3
    Last Post: 01-02-2015, 12:55 PM
  3. Replies: 1
    Last Post: 08-29-2012, 07:25 PM
  4. Replies: 5
    Last Post: 08-08-2012, 01:30 PM
  5. Replies: 33
    Last Post: 01-13-2012, 07:44 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