Results 1 to 4 of 4
  1. #1
    G4L is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Apr 2011
    Posts
    2

    Populating subform using main form details

    I have 2 tables: Project table and Estimates table



    Project Table fields:
    Project ID
    Proj Name
    Desc
    Start Date
    End Date

    Estimate fields:
    Department
    # of days
    $/day
    Total Estimated Cost (basically # of days * $/day)

    So what i want to do is that I want to find out what department is working on a specific project and the amt of days and estimated cost each department will have

    So in my main form i have the project code, department, #of days and $/day

    what i want to do is that whatever ive typed in the fields (see the sentence above for the fields) in the main form will be shown in the subform so that it will be easier for me to read the data as I add multiple departments into a project

    But unfortunately im stuck as i dont know how to update the sub form once ive entered all the fields in the main form
    Last edited by G4L; 04-04-2011 at 02:02 PM. Reason: typo

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Welcome to the forum.

    If a project can have many departments working on it you have a one-to-many relationship, so you need to relate the project table with the estimate table

    Some general recommendations:
    It is best not to have spaces or special characters in your table or field names
    In most cases, calculated values are not stored but rather calculated on the fly when you need them in forms, queries or reports.

    So with those recommendation in mind, this is how your tables should be structured.

    tblProject
    -pkProjectID primary key, autonumber
    -ProjName
    -Desc
    -StartDate
    -EndDate

    tblDepartment
    -pkDeptID primary key, autonumber
    -DeptName

    tblEstimate
    -pkEstimateID primary key, autonumber
    -fkProjectID foreign key to tblProject
    -fkDeptID foreign key to tblDepartment
    -NumberOfDays
    -DailyCost

    In terms of forms, your main form would be based on the project table with a subform based on the estimate table. You would populate the department using a combo box based on the department table.

  3. #3
    G4L is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Apr 2011
    Posts
    2
    hey, i should have elaborated on my table fields...i did have the names of the fields named differently without any spaces or special characters and i do have a department table with the dept name and a pk for the dept id

    but the problem i have is that im trying to populate data from the main form to the sub form for the estimates but for some reason i cant get it to work

  4. #4
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You would only need to populate the foreign key field that relates to the primary key of the project table. If you did not have your relationships established in the relationship window before creating the main form/sub form you will have to create the join between the forms manually. To do this open the main form with the subform in design view, double click the frame of the subform (it should bring up the property sheet). Look for the data tab and then the two properites (link child fields and link master fields). Click in one of them and select the appropriate fields from each table to make the join.

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

Similar Threads

  1. Subform in a Tab Control on a Main form
    By jpkeller55 in forum Access
    Replies: 4
    Last Post: 01-08-2011, 12:31 PM
  2. opening a second form from main/subform
    By PJPCVP in forum Database Design
    Replies: 1
    Last Post: 10-29-2010, 09:50 PM
  3. Subform won't display in main form
    By Lynn in forum Forms
    Replies: 15
    Last Post: 03-22-2010, 10:17 AM
  4. Linking Subform Control to Main form
    By KWarzala in forum Forms
    Replies: 1
    Last Post: 03-13-2010, 08:32 PM
  5. Subform vs main form calculation
    By fadone in forum Forms
    Replies: 17
    Last Post: 12-21-2005, 07:27 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