Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    AndyRob1973 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2020
    Posts
    81

    A simple input form for a one to many, many to one, 3 table relationship

    Hi all,


    I have a database where I have a ‘student’ table, a ‘course table’ and an ‘enrolment’ table.

    A student can enrol on one or more courses and each course can have more than one student.

    I have set up my relationships as below:

    STUDENT (1----------Many) ENROLMENTS (Many-----------1) COURSES

    I would like to build an input form where I can enrol a student on a course.

    Ideally I could choose from pre existing students and courses but also add new ones on the form (but that can wait)

    Could anyone point me to any simple sample forms or tutorial that will help me with this. For starters it only needs to be basic and I will build on it gradually.

    Thank you

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    I use list boxes. Source list, dbl-click to run append query to add to the Target table. (list)
    The Accept button not always needed.
    Attached Thumbnails Attached Thumbnails pick state lbls.png  

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,537
    Quote Originally Posted by AndyRob1973 View Post
    Hi all,
    I have a database where I have a ‘student’ table, a ‘course table’ and an ‘enrolment’ table.

    A student can enrol on one or more courses and each course can have more than one student.

    I have set up my relationships as below:

    STUDENT (1----------Many) ENROLMENTS (Many-----------1) COURSES

    I would like to build an input form where I can enrol a student on a course.

    Ideally I could choose from pre existing students and courses but also add new ones on the form (but that can wait)

    Could anyone point me to any simple sample forms or tutorial that will help me with this. For starters it only needs to be basic and I will build on it gradually.

    Thank you
    The attached db may give you some ideas
    Attached Files Attached Files
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    Here's another working example:

    https://www.accessforums.net/showthread.php?t=79814

  5. #5
    AndyRob1973 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2020
    Posts
    81
    Thank you all,

    I shall have a look and digest these - I think they have put me on the right lines!

  6. #6
    AndyRob1973 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2020
    Posts
    81
    Thank you to all who helped on this. I have something which works.

  7. #7
    AndyRob1973 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2020
    Posts
    81
    Hi Bob,

    I’ve been using the Student Database example that you sent me very successfully.
    There are a couple of parts that I’m having a little struggle with.

    I have added a button which allows the user to add a new course into the tblCourses table. When I click the ‘find’ button I can see the new course but when I select it, the details below do not change.

    However, if close the form and reopen, click on this new course, it DOES change the details.

    It is obviously requerying when I reopen the form but how do I force that to happen without closing a reopening the form?

    Thanks

  8. #8
    AndyRob1973 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2020
    Posts
    81
    Hi Bob,

    I’ve been using the Student Database example that you sent me very successfully.

    There are a couple of parts that I’m having a little struggle with.

    I have added a button which allows the user to add a new course into the tblCourses table.

    When I click the ‘find’ button I can see the new course but when I select it, the details below do not change. However, if close the form and reopen, click on this new course, it DOES change the details.

    It is obviously requerying when I reopen the form but how do I force that to happen without closing a reopening the form?

    Thanks.

  9. #9
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,537
    Quote Originally Posted by AndyRob1973 View Post
    Hi Bob,

    I’ve been using the Student Database example that you sent me very successfully.

    There are a couple of parts that I’m having a little struggle with.

    I have added a button which allows the user to add a new course into the tblCourses table.

    When I click the ‘find’ button I can see the new course but when I select it, the details below do not change. However, if close the form and reopen, click on this new course, it DOES change the details.

    It is obviously requerying when I reopen the form but how do I force that to happen without closing a reopening the form?

    Thanks.
    I'll look into it
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  10. #10
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,537
    AndyRob1973
    I've had a look at the example db that I originally posted for you but my memory is not good enough to remember what exactly I was trying to demonstrate.
    To add courses I would often use the "Not on List" of a combo box at the point where the user finds that the required course is not on the list.
    I have added a button which allows the user to add a new course into the tblCourses table.
    If you post a copy of your db I'd be happy to have a look at your current proplem.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  11. #11
    AndyRob1973 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2020
    Posts
    81
    Hi Bob

    When you open the database (which holds dummy nonsensicaldata), from the menu choose ‘Manual Payment input’ form.

    Then on the form that appears, click ‘add new study todatabase’.

    Add a new study (just put anything – IRAS is a number but itdoesn’t matter). Save it.

    Go back to the ‘Manual Payment input’ form and choose thenew study from the dropdown.
    The information below stays the same as it was for theprevious selection.

    Thanks

    Andy

    Attached Files Attached Files

  12. #12
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,537
    Use the following line of code in the "Got Focus" event of the combo box called "cmbFind" and labelled "Choose study".
    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
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,537
    Alternatively, you could use the following line the "After Update" event of the form called "frmStudies".

    Forms!frmMF_StudyRecruits.cmbFind.Requery


    FWIW my personal preference would be to NOT have a button to open "frmStudies" but use the "Not On List" event of the "cmbFind" combo box to open "frmStudies". Let me know if you'd like to try that approach instead.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  14. #14
    AndyRob1973 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2020
    Posts
    81
    Quote Originally Posted by Bob Fitz View Post
    Use the following line of code in the "Got Focus" event of the combo box called "cmbFind" and labelled "Choose study".
    Thank you Bob - did you mean to put some code in here?

  15. #15
    AndyRob1973 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2020
    Posts
    81
    Quote Originally Posted by Bob Fitz View Post
    Alternatively, you could use the following line the "After Update" event of the form called "frmStudies".

    Forms!frmMF_StudyRecruits.cmbFind.Requery


    FWIW my personal preference would be to NOT have a button to open "frmStudies" but use the "Not On List" event of the "cmbFind" combo box to open "frmStudies". Let me know if you'd like to try that approach instead.
    Thanks again Bob - yes i would be interested in that alternative approach - the more options and learning the better!

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Relatively simple relationship question
    By Rendon115 in forum Access
    Replies: 2
    Last Post: 05-21-2020, 05:27 PM
  2. Data Input Many to Many relationship
    By sharkey_lsu in forum Database Design
    Replies: 5
    Last Post: 02-10-2015, 06:30 PM
  3. Establishing a simple relationship?
    By Harry2 in forum Access
    Replies: 7
    Last Post: 06-16-2014, 02:41 PM
  4. Replies: 3
    Last Post: 01-24-2014, 10:45 AM
  5. Simple input mask
    By BPB6 in forum Access
    Replies: 8
    Last Post: 10-18-2012, 06:34 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