Results 1 to 15 of 15
  1. #1
    ludovic_44 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2014
    Location
    mauritius
    Posts
    15

    Adding subforms on a main form

    Click image for larger version. 

Name:	Subform Issue.jpg 
Views:	26 
Size:	80.4 KB 
ID:	16263Hi All,

    Im quite new to access , i have created a main form as attached where we have several buttons on the left and a subform in the middle on its right.
    I want to display a subform based on the button click, i have already created all the forms , but i dont know how to display the subform individually in the main form by clicking on the button on the right, i really have to know it because of a project which im planning to do.



    Your help will be highly appreciated


    Thanks for your prompt answer guys as i'm really in great trouble

    Ludovic

  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
    Your code would set the source object property of the subform control to the desired form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ludovic_44 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2014
    Location
    mauritius
    Posts
    15
    @pbaldy:
    can you please tell me the code, realy i dont know the code. thanks for your reply
    i have just create the for without even knowing how to proceed to do this, well i just hope this can be done now

    Ludovic

  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
    Me.SubformControlName.SourceObject = "FormName"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    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 deleted your duplicate thread. Please don't post the same question twice.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    ludovic_44 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2014
    Location
    mauritius
    Posts
    15
    Im sorry guys,
    I inserted this : Private Sub Command47_Click()
    Me.frmDevelopment.Form = frmDevelopment
    End Sub

    @pbaldy told me to use the below syntax:
    " Me.SubformControlName.SourceObject = "FormName"
    i replaced SubformControlName by the name of the form which is "frmDevelopment"
    and SourceObject as "Form"

    I that the way of doing this please

  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
    Leave SourceObject alone, and put the form name in quotes, like I had it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    ludovic_44 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2014
    Location
    mauritius
    Posts
    15
    @Pbaldy:
    It works for the 1st button only when i applied same for the remaining it does not work, it shows an error:
    Compile Error
    Method or Data member not found

    Please help me, im near! i have drag only one form as subform on the main form.
    Do you think thats why i cant apply it for the remaining

    Ludovic

  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,521
    No, you should be able to use a different form name for each button.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    ludovic_44 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2014
    Location
    mauritius
    Posts
    15
    Thanks very much
    Thats what i did, but it does not work for the others.
    When i drag a form ton my Main form as Subform, the name of the subform is the same as one of my form.(frmdevelopment)
    and i have 15 more begins by frm and followed by the button name i have inserted as attached.

    Do you think that this may cause an issue

  11. #11
    ludovic_44 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2014
    Location
    mauritius
    Posts
    15

    Adding subforms on a main form

    test1.zip

    I have zip it as attached, please can you have a look, thanks for your kind help

    Ludovic

  12. #12
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,543
    Can you post a copy in A2003 mdb format.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  13. #13
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Do not understand this db. You have about a dozen identical forms structured like the one on the right, the only difference between them is a label at top. There is no code behind these forms and they are unbound. There aren't even tables to go with the forms. It appears you have 'jumped the gun' to building forms before the data structure is even set up.

    A subform/subreport is created by installing a subform/subreport container control on another form. The container SourceObject can be table, query, form, report. It is a good idea to name container different from the object it holds, like ctrWorkshops. Your container is named frmDevelopment (also have a form by that name) and at present it holds a form named frmBreakDown. Why is BreakDown not in the list on the left?

    You want to use code behind the buttons to change the container SourceObject. The code behind each button will have an expression like:

    Me.frmDevelopment.SourceObject = "whichever form name you want to show in the container"

    The code does work.
    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.

  14. #14
    ludovic_44 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2014
    Location
    mauritius
    Posts
    15
    Hi June 7,

    Wow, im impressed because you have really analyse the DB , yeah i created this form without any code as you can see, and all the button in the subform in the left are the same except the label in the top is different, because i have not yet add the proper button and label in each of th form,
    Would you please Sir, to modify it for me so that i can deeply understand the container and the parent and the form to be created, then i can work it in my level,
    Because i badly need it and i dont know how to input the code and let it works

    I want that the subform appears in the main form when i clicked the button on the left,
    The frm breakdown is the same as Mobile Service, instead of inserting Breakdown, i have written mobile service

    Thanks for your great help, i think your help wll really relieves me

    Please

    Ludovic

  15. #15
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    No, I do not want to do this work for you. You already have code in place for two buttons. Just fix the form name for each as described in my post and uncomment the line in one of them. Then create the similar code behind the other buttons. All I did in your db was fix the code for the two buttons and it worked. This is a simple fix you should be able to accomplish. Even without edits, did not get error message.
    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.

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

Similar Threads

  1. How to refer to fields in subforms from Main form
    By JrMontgom in forum Programming
    Replies: 1
    Last Post: 03-09-2014, 06:35 PM
  2. Replies: 19
    Last Post: 05-13-2013, 01:26 AM
  3. Multiple subforms to one main form
    By mick3911 in forum Forms
    Replies: 8
    Last Post: 02-25-2013, 09:40 PM
  4. Replies: 1
    Last Post: 08-02-2012, 02:11 PM
  5. Replies: 0
    Last Post: 12-16-2008, 07:49 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