Results 1 to 5 of 5
  1. #1
    AndyRob1973 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2020
    Posts
    81

    Open one form from another form passing the linked field

    Hello all,


    I have a main table (students) with students basic information (eg name, Date of birth, address, contact number) and have made a form. The primary key is StudentID.

    StudentID (PK)
    Name
    DOB
    Address
    Contact Number

    I have created another table (demographics) where I want to hold the student’s demographic details

    DemographicID (PK)
    StudentID
    Gender
    Ethnicity

    I have linked these tables in ‘relationships’ (with ‘enforce referential integrity’, ‘cascade update related fields’, ‘cascade delete related fields’, all ticked) on StudentID.

    I have then made a form from the students table and another form from the demographics table. I would like to open the student form and input details then click on a button to open the demographics form and fill in the demographic details for that student. How do I get the StudentID to be passed when I open the demographics form so that I’m adding this data to the correct student?

    Could anyone help please? I suspect this is easy but I'm struggling.

    Thankyou

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,412
    Having two tables make little sense. This is a one-to-one relationship. Student gender and ethnicity is constant and should be in the Students table. No demographic table required.

    However, if there is a reason for separate tables, check out the Openargs parameter for DoCmd.Openform

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    on the main form is fStudent
    add a subform fDemoSub, (the tDemo table)

    set the properties on the subform:
    LINK MASTER FIELDS: StudentID
    LINK CHILD FIELDS: StudentID

    then just fill in the subform fields. (studID fills itself)

  4. #4
    AndyRob1973 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2020
    Posts
    81
    Thankyou both

    I’m sorry – my question was a really clumsy way of asking for what I wanted by using a made up example!
    Basically I would like to know how to open another form rather than just have a sub form. A better example might be a student form and an Emergency Contact form (one to many)

    StudentID (PK)
    Name
    DOB
    Address
    Contact Number

    Emerg_ContID (PK)
    StudentID
    Name
    MobileNum

    I understand that I could have it as a subform but would like to know how to open the EmergencyContact form for that student, by pressing a button on the Student form
    Thankyou and sorry for the confusion!

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,933

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

Similar Threads

  1. Replies: 2
    Last Post: 07-26-2018, 01:32 PM
  2. Replies: 4
    Last Post: 05-11-2018, 04:52 AM
  3. Passing Form Field Value to Query
    By calgarianguy in forum Forms
    Replies: 1
    Last Post: 06-11-2013, 09:35 PM
  4. Code for button to open new form passing value
    By cptNemo in forum Programming
    Replies: 3
    Last Post: 09-13-2012, 09:46 PM
  5. Replies: 4
    Last Post: 03-01-2012, 08:15 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