Results 1 to 4 of 4
  1. #1
    bench is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    2

    Command Button to Switch Between Subdatasheets

    Hi,

    Very very new to Access, have some experience with excel vba but have learned most of this through the macro recorder, now i find out access doesn't have a macro recorder



    My issue:

    I have a database with contacts in (company name, address, phone number etc), each of these have three subdatasheets attached (i may be referring to this by the wrong name, i mean a related table), what i would like to do on my entry form is allow the user to click one of three command buttons that will then show the relevant subdatasheet (People, Postcodes, Instructions) I imagine this is really easy wondered if anyone could give me a kick start please.

    Thanks

    Ben

  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
    I think that so much of what one would want to do in Access does not lend itself to being "recorded" that having such functionality doesn't make sense. I think you'll find that the wizards will accomplish a similar goal for you.

    To the point, I can think of a couple of potential solutions (both of which use forms based on your tables as subforms, not the tables themselves). The first is a little less efficient but maybe easier. You can put a tab control onto your form with 3 tabs. On each tab would be a subform based on the appropriate table. The user would click on the appropriate tab to see that data.

    The second method would be to have one subform control on the form. Behind your buttons, you set the SourceObject property of that control to place the desired subform in there:

    Me.SubformControlName.SourceObject = "FormName"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    bench is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    2
    Quote Originally Posted by pbaldy View Post
    To the point, I can think of a couple of potential solutions (both of which use forms based on your tables as subforms, not the tables themselves). The first is a little less efficient but maybe easier. You can put a tab control onto your form with 3 tabs. On each tab would be a subform based on the appropriate table. The user would click on the appropriate tab to see that data.

    The second method would be to have one subform control on the form. Behind your buttons, you set the SourceObject property of that control to place the desired subform in there:

    Me.SubformControlName.SourceObject = "FormName"
    These both sound ideal options. I'm really new to all this so appreciate any further help you can give me.

    For the second option you gave me i added a couple of command buttons right clicked on build event, build code then added in your code as above, replacing the "FormName" with my subforms name.

    When i run it it errors highlighting ".subControlName" - Method or Data Name not found. I imagine i have to set this to an actual name in my own database(?) where would i find this?

    ON THE TABS OPTION where and what would i put to command the change between subforms?

    Really appreciate any help on this.

    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
    Yes, that has to be the name of the subform control, which may or may not have the same name as the actual subform. If you go into design view of the form and click ONCE on the subform, you can go into the properties of the subform control (otherwise you'll be in the properties of the subform itself). That will tell you what its name is.

    On the tabs option, no code would be required. You would put a different subform on each tab. The user clicking on each tab would be how they would view each subform.
    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: 1
    Last Post: 07-27-2010, 02:27 PM
  2. Command Button
    By nashr1928 in forum Forms
    Replies: 2
    Last Post: 07-05-2010, 08:02 PM
  3. Command Button
    By nashr1928 in forum Forms
    Replies: 1
    Last Post: 07-05-2010, 07:05 PM
  4. Command Button
    By lannoe in forum Forms
    Replies: 1
    Last Post: 07-01-2010, 01:48 PM
  5. Command Button Help!
    By arthura in forum Programming
    Replies: 3
    Last Post: 06-30-2009, 12:55 PM

Tags for this Thread

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