Results 1 to 7 of 7
  1. #1
    benthamq is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    32

    Tabular Control Code

    Hello All,



    I am new to Access 2010 and greatly appreciate any help you can offer.

    I have a form with a tabular control and one of the tabs contains a subform.

    I want to put a button in the subform that will automatically create another tab in the tabular control with another blank copy of the subform in it. I need to do this because the subform contains data from a query that is in a many to one relationship with the data in the main part of the form, and it is possible sometimes that the user will need to enter additional records in the subform for the one record that is in the main part of the form. By having a button that automatically opens a new tab with a blank copy of the subform he will be able to do so easily.

    What code should I write for the click event of the button on the subform to accomplish this?

    Thanks so much for any help!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Cannot open duplicate instances of the same form. What you need to do is move to a new record of the subform. The subform is set for SingleForm view?
    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.

  3. #3
    benthamq is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    32
    Thanks for your reply.

    I guess my initial question was pretty dumb. Noted that you cannot duplicate the same subform. I am still learning.

    So the solution then is to have multiple records in the subform - understood.
    That brings up this related question:
    When the form is opened, therefore, I need it so that the only records available in the subform are ones that apply to the open record in the main form (plus the option to add a new record in the subform, of course.)
    How can this be accomplished? It seems like I would have to use the primary key field of the record in the main form to set a filter for all the records in the subform but I don't have any idea what code to write for this.

    Sorry if this is very tedious question to answer - thanks for your help.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    A subform is really just a form. What makes it different is that it is held in a Subform Container Control. This control has Master/Child link properties that will synchronize the recordsets of the main and sub forms. Set these properties to the primary and foreign key fields of the two forms.

    Even if a form is set to SingleForm view, its RecordSource can still be multiple records. Just depends on the filter criteria. The view setting just determines if you can see more than one record at a time, as in Datasheet View. The navigation bar will allow you to move from record to record.
    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.

  5. #5
    benthamq is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    32
    "This control has Master/Child link properties that will synchronize the recordsets of the main and sub forms. Set these properties to the primary and foreign key fields of the two forms."

    Would it be possible for you to explain how to set the master/child link properties? Is this the same as creating a relationship?

    Also, what is the general wisdom, if it exists, regarding basing a form on a table versus basing a form on a query? I know sometimes you must base it on a query if all the fileds you need to update are not present in the table but if they are, is it OK to base the form on the table?

    Thank you very much.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Master/Child links are properties of the subform container control. Select the container, open Properties dialog, go to Data tab. It is like creating a relationship, but only for this form/subform. If you have established relationship in the Relationship builder, then the control might automatically set the links when it is created on the form, or maybe that requires using wizard which I never do.

    I have seen advice against table as direct recordsource but I have never experienced an issue with basing a form/report on a table, however, most of my forms/reports are based on a query because usually need joined tables.
    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
    benthamq is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    32
    Thanks - At first, I couldn't find the subform container control to set the master/child link properties but now I have and I have done exactly as you explained and the form/sub form are working perfectly together.

    I will mark this solved.

    Thanks again.

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

Similar Threads

  1. Replies: 4
    Last Post: 05-24-2011, 08:19 AM
  2. Tabular Data Design
    By Ramsi2001 in forum Forms
    Replies: 53
    Last Post: 08-25-2010, 06:38 PM
  3. Tabular Form
    By Evgeny in forum Forms
    Replies: 0
    Last Post: 04-26-2010, 08:39 PM
  4. Null Date control code problem
    By DanW in forum Forms
    Replies: 2
    Last Post: 11-10-2009, 03:13 PM
  5. Positioning Tabular Labels
    By rod147 in forum Forms
    Replies: 6
    Last Post: 07-06-2009, 11:02 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