Results 1 to 4 of 4
  1. #1
    jalal is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2012
    Posts
    17

    Create a combo to fetch record in a subform

    I Created three tables: 1. students, 2. subjects, 3. Marks. The Students table have a unique code for each student, with field name as StudentID, so the Students table contains fields:
    a) StudentID a unique code for each student.
    FirstName
    Address
    Phone
    b) The Subjects table will have fields:
    SubjectID a unique code for each subject.
    Subject full title of the subject
    c) The Grades table have just three fields:
    StudentID a code that ties this entry to a student in the Students table
    SubjectID a code that ties this entry to a subject in the Subjects table
    Grade the mark this student achieved in this subject.
    After creating the three tables, Margaret needs to create a link between them. In Access 2007 and 2010, Relationships is on the Database Tools ribbon. In Access 95 - 2003, Relationships is on the Tools menu (or the Edit menu in Access 1 -2.) "Grades" will be the "related table" in relationships with both the other tables.
    Now I could enter all the students in the Students table, with the unique StudentID for each. I enter all the subjects in the Subjects table, each with a SubjectID. Then at the end of term when the marks are ready, I could enter them in the Grades table.
    To enter marks, I created a form, using the "Form/Subform" wizard: "Subjects" is the source for the main form, and "Grades" is the source for the subform. Now with the appropriate subject in the main form, and adds each StudentID and Grade in the subform.


    The grades were entered by subject, However to view them by student. I created another form/subform, with the main form reading its data from the Students table, and the subform from the Grades table. Since I used StudentID when entering grades in the previous form, Access linked this code to the one in the new main form, and automatically displays all the subjects and grades for the student in the main form.
    Now I would like to create a combo search field in the Header or anywhere in the main form to find the record based on StudentID in the Subform.
    Please help
    Jalal

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I presume you want to have this search functionality on the first form/subform (Subject is the main form) because doesn't make sense if you mean the second form. In that case the second form/subform is irrelevant to the question.

    Google: VBA Access find record subform

    Here is one example:
    http://bytes.com/topic/access/answer...ecord-sub-form
    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
    jalal is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2012
    Posts
    17
    Thanks for early reply
    I suppose I could not make my query in proper way. However I repeat my problem.

    Question?
    I Created three tables
    A) tblStudents (fields are (1) ID as a Primary Key Autonumber
    (2) StudentID again with a unique code
    (3) FirstName
    (4) Level etc.

    B) tblSubjects (Fields are (1) SubjectsID with a unique code
    (2) Subjects - details

    C) tblMarks (fields are (1) (PaperA represents Marks for Paper A e.g. English A
    (2) (PaperB represents Marks for Paper B e.g. English B etc
    (3) Total Marks (which will indicate PaperA + PaperB)

    I opened the tblMarks in datasheet view and dragged two fields – (a) StudentsID from tblStudents and (b) SubjectsID from tblSubjects into it there by creating a one-to-many relationship
    I created a Forms StudentsMain form through Forms wizard with source as tblStudents selecting StudentID as first field. Then to create a subform, I selected from the tblMarks as source the fields SubjectsID, PaperA, PaperB into it. While completing the wizard I gave the name of the Form as StudentsMain and Sub Form named as StudentsMarks Subform.
    It was through the StudentsMain form I could select maximum 5 subjects for each student (Desirable).
    Again I created a Forms as SubjectsMain form through Forms wizard with source as tblSubjects selecting SubjectsID as first field. Then to create a subform, I selected from the tblMarks as source the fields StudentsID, PaperA, PaperB and TotolMarks into it. While completing the wizard I gave the name of the Form as SubjectsMain and Sub Form named as SubjectsMarks Subform.
    It was through the SubjectsMain form I could enter the marks obtained by the students in 5 subjects.

    This way I am successful. But In case thate are hundreds of students then it becomes combesome to give marks to each student as it takes one complete cycle to reach again on the first record.

    Now I would like to create a combo search field in the Header or anywhere in both the main forms i.e Studentsmain and SubjectsMain. In order to entre marks of all the subjects obtained by the student I must get the information through a combo box or through GoTo Command in the StudentsMainForm. Besides this will help me to find the status of result of any student at any given time.

    Please help
    Jalal

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    An unbound combobox on StudentsMain to search for specific student and see all that student's marks is simple enough. This is a filter or go to of the main form records. The combobox wizard can create that for you. It will be a macro. Then if you want VBA can convert the macro.

    If you want a combobox on SubjectsMain to filter the SubjectsMarks subform, I did provide a link with VBA example for you to adapt. Make attempt and post for analysis.

    Filtering or go to record are common topics. Search forum or Google.
    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.

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

Similar Threads

  1. Fetch Data From MS-Access
    By kashif.special2005 in forum Programming
    Replies: 1
    Last Post: 08-27-2011, 05:50 AM
  2. Replies: 5
    Last Post: 03-11-2011, 11:28 AM
  3. Create new record in subform
    By david.paige in forum Forms
    Replies: 3
    Last Post: 08-16-2010, 02:00 PM
  4. Need Query to fetch last row in a table
    By gunapriyan in forum Queries
    Replies: 10
    Last Post: 02-20-2010, 12:46 AM
  5. Create combo search form in subform
    By grant.smalley in forum Forms
    Replies: 6
    Last Post: 02-19-2010, 04:37 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