Updating fields in a subform after user inputs number

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sadiejane
    New Member
    • Dec 2009
    • 4

    Updating fields in a subform after user inputs number

    Hello,
    I have created a database that will eventually look up grades for a teacher. It is easier for me to learn if I actually have a project. So I took this one on for a friend who is a teacher. So far so good.

    I am now creating a form which has a subform, and would like her to enter the student number and then the subform will update with that particular student, name , and number. i have looked at a lot of previous posts, but am too new to decipher exactly to my situation.

    Any help or guided direction would be great. I am working in 2007.

    Thank you in advance,

    Sadie
  • topher23
    Recognized Expert New Member
    • Oct 2008
    • 234

    #2
    Welcome Sadie!

    I don't know how much of a beginner you are, so I'll explain this at a really basic level. Please don't be offended.

    The key here is the linked fields between the parent form and the subform. When you open your parent form in design view, click on the subform and select the Data tab in your properties window. You'll want "Link Child Fields" set to the student number on the subform, and "Link Parent Fields" set to the text box on the parent form.

    You'll also want to make sure the recordsource for the subform is set up to the table holding student information. The recordsource for the main form isn't material to the situation.

    Now, click on the text box on your parent form. Go to the Properties window and click the Event tab, then click the ellipsis (...) at the end of AfterUpdate and select Code Builder. Paste in this code.
    Code:
    Me.[YourSubFormName].Requery
    Replace YourSubFormName with the name of your subform control.

    Now, when you type in a student number in the main form, the subform will check the records in its recordsource and display the record with that number.

    I hope this helps!

    Comment

    • Sadiejane
      New Member
      • Dec 2009
      • 4

      #3
      I am trully a beginner that gets way over my head quickly. This helps alot and will try shortly to get it working.

      Thank you,
      Sadie

      Comment

      • Sadiejane
        New Member
        • Dec 2009
        • 4

        #4
        Just a little bit more help

        I got the subform and form working together. Thank you for your help. But now I added a field, in the main form so you could enter the student number and all fields will populate. I tried to do it in the fields that I just made work and can't get that to work so I added a field. Probably not the best approach. I have attached the db, maybe it would make more sense if you looked at it. It is the frmStudents.

        Thank you again for your time and efforts.

        Sadie
        Attached Files

        Comment

        • Sadiejane
          New Member
          • Dec 2009
          • 4

          #5
          I got it working, thank you for your help. All I had to do was change the fields I was looking for in the search button.

          Thank you again,

          Sadie

          Comment

          Working...