Results 1 to 12 of 12

Thread: How Do I link Forms and access them through a Command Button?

  1. #1
    skyrise is offline Novice
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Feb 2009
    Posts
    22

    Unhappy How Do I link Forms and access them through a Command Button?

    Have I screwed up?

    I have 3 forms that are related to each other Ė Forms 2 and 3 contain subset information about the subject started on Form 1.

    Iím getting stuck on how to link the forms together and add a button on Form 1 that will open Form 2, and a button on Form 2 that will open Form 3. The other option is to have each Form appear a tab that can be clicked by the user.

    Right now, I have built each individual form (with itís subforms). I have the Primary Key field from Form 1 on Forms 2 and 3. I canít though, get the record number from Form 1 to auto populate on the other forms to show that all the data is related.

    Is there a way to fix this and add the command buttons or tabs, or will it be better for me to take a different approach and start from scratch?

    What am I missing? Did I skip a step in the process or get something out of order?

  2. #2
    skyrise is offline Novice
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Feb 2009
    Posts
    22
    I would say that I'm trying to set up a sub form scenario. The information for one subject is being broken out into three sections (the 3 forms). Each section contains its own list of data (fields on the forms).

    For example. If the database is for Car Accidents.
    Table/Form1 = Identification info
    Table/Form2 = Cause info
    Table/Form 3 = Effect info

    All 3 forms contain information that pertains to 1 car accident. Each subsequent car accident record would then have its data split onto the 3 forms.

    I'm used to subforms appearing imbedded on the Parent form. I would like Forms 2 & 3 to appear a full screen page (like Form 1) when they are being used.

    I'm assuming that an Open Form Command Button or a Tab Page setup is the best way to try to get there?

  3. #3
    skyrise is offline Novice
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Feb 2009
    Posts
    22
    I have attached a sample database of what Iím working on. The database Iím putting together includes a lot more fields and subforms, but the sample here provides a good mix of the variety of content I am trying to connect and relate together.

    Form 1 = Study
    Form 2 = Participants
    Form3 = Study Design

    There are main form fields, look up fields, multiple entry subforms.

    I would like to keep these forms separated but connect them to the same data record (keyed off of Study Form 1).

    Perhaps a Command Button at the bottom of each form that contains an Event Procedure that links the Primary/Foreign fields on each form and then opens the next form.
    Attached Files Attached Files

  4. #4
    skyrise is offline Novice
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Feb 2009
    Posts
    22
    Sample as a 2002/2003 database.
    Attached Files Attached Files

  5. #5
    mat
    mat is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2010
    Posts
    1
    Hello,

    I think I've been wrestling with a similar problem: creating new records in a form linked to (but not a subform of) a master form.

    Am I right in thinking your problem is how to automatically populate the primary key of the record in the master form as the foreign key of the new record in the child form?

    I've found a way round this:
    If the master form is loaded whilst you are creating the new record in the child form, you can set the foreign key by using a hidden text box with its "default value" set to a reference to primary key control on the master form.

    For example, you have a command button on frmParent that opens frmChild, and allows you to add new child records, linked on foreign key "ParentID". Simply create a hidden textbox "txtParentID". Make its control source equal to the foreign key on the Child table "ParentID" and make its default value in the Properties of the textbox equal to:
    Forms!frmParent!txtParentID.Value.
    (by the way, you need txtParentID on the Parent form too, but it can be hidden).

    Then, as long as the parent form is open, it will add the new record with the correct foreign key.

    Hope this helps.

  6. #6
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    927
    This is what I understand from your thread:

    1) You have a main information table and related to that you have multiple related tables.
    2) You have created forms accordingly. A main form that is required to be filled in first. It generates the Link_ID that has to be passed on to the subsequent Link_forms when they open.

    So now my suggestion:

    make sure you set the Data Entry property for all your sub-forms is set to Yes. This will ensure that the Link Forms will always open blank.

    Now make a commandbutton to ope a LinkForm:
    Include this code in it:
    Forms!NameofLinkForm!FieldName=Me.FieldName
    Me.FieldName is the Field whose value you want to pass on to the Link-form. See the result. Now Once you do this is this field that you update is linked to the sub-form of this link form it will take up its value.

    if this solves your problem please mark the thread solved.

  7. #7
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    927
    is your problem solved
    Note: Please change the names of the tables, queries, form, controls in the example with the ones in your database

    How to Mark a thread solved:
    http://www.accessforums.net/forum-su...lved-1828.html

    Contact
    for Solutions to your database problems and at affordable rates
    silverback_bats@yahoo.co.in / m.exodus2@gmail.com

  8. #8
    skyrise is offline Novice
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Feb 2009
    Posts
    22
    Thanks guys, this is solved.

  9. #9
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    927
    mark this thread solved
    Note: Please change the names of the tables, queries, form, controls in the example with the ones in your database

    How to Mark a thread solved:
    http://www.accessforums.net/forum-su...lved-1828.html

    Contact
    for Solutions to your database problems and at affordable rates
    silverback_bats@yahoo.co.in / m.exodus2@gmail.com

  10. #10
    funi.t is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    52
    hi I have a similar problem but the forms that I would like to open are not immbedded in the main form.I would like the linked forms to automatically take the data that I've entered in the main form when i open them(linked forms).

    When i include the code:"Forms!NameofLinkForm!FieldName=Me.FieldName" .Do i do this under the "view code" in design when the main form is in design view?

  11. #11
    funi.t is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    52
    okay this is what i intend to do.
    I have a main form and would like to enter a few search fields on this form.The entered fields should then appear on the linked forms when i open the form and retrieve all data that is linked to the search fields.
    Please help

  12. #12
    EW1587 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    1
    This very similar problem to what I'm facing. Help would be appreciated.

    I have a SearchForm that access a query to allow a user to find an organization in my table of organizations. Then, it displays the results in a Report.

    My goal is to have a command button that allows the user to initiate a disbursement to an organization from the displayed results Report and to pre-select the Organization Name option in the disbursement form.

    The trick is the disbursement form will create a new record in a different table than the Organizations table. I have the primary key in the Organizations table linked to the organization name field in my disbursements table but I can't seem to navigate that link such that my Command Button to "Create Disbursement" uses the Organization name from the Results Report and returns the Organization name in the Create Disbursements Form.

    Any help or advice would be much appreciated.

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

Similar Threads

  1. Create a command button to Browes for file
    By sawill in forum Programming
    Replies: 3
    Last Post: 03-15-2009, 04:02 PM
  2. Duplicate command button
    By brettg in forum Database Design
    Replies: 1
    Last Post: 08-04-2008, 03:16 AM
  3. Command button code
    By lfolger in forum Forms
    Replies: 3
    Last Post: 03-25-2008, 03:26 PM
  4. Command button for time & date
    By joet5402 in forum Forms
    Replies: 2
    Last Post: 12-20-2007, 12:59 AM
  5. Open a linked subform with a command button
    By flablueeyedblond in forum Forms
    Replies: 0
    Last Post: 11-18-2005, 11:18 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
  •  
Tech Forums: Microsoft Office Forums