Results 1 to 5 of 5
  1. #1
    sockswithsandals is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2012
    Posts
    7

    Connecting periods from different tables - database design problem


    This is really driving me crazy! I am not experienced Access user first of all.

    I'm trying to build a database where would be project allocations per person per period (month) (could be many projects) and persons would also report their actual hours per project per week (so several reports per person per project) but I don't know how to connect these periods from different tables. Now when I run a query I'll get everything multiple times as hour report period 4 shows all allocations etc. How this should be done...? I would really appreciate any help...
    Attached Thumbnails Attached Thumbnails DB_rel.PNG  
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Instead of repeating the UserID, ProjectID, FY, Period in tblRepHours, save the SPID pk from tblStaffProj as fk. Otherwise, do a join between those two tables on 4 fields:

    SELECT tblProj.ProjID, tblProj.ProjName, tblRepHours.USERID AS tblRepHours_USERID, tblRepHours.FY, tblRepHours.RHPeriod, tblRepHours.RepHours, tblStaff.USERID AS tblStaff_USERID, tblStaff.StaffF, tblStaff.StaffL, tblStaff.StaffT, tblStaffProj.APct, tblStaffProj.APeriod
    FROM tblStaff RIGHT JOIN ((tblProj RIGHT JOIN tblStaffProj ON tblProj.ProjID = tblStaffProj.[ProjID]) RIGHT JOIN tblRepHours ON (tblStaffProj.APeriod = tblRepHours.RHPeriod) AND (tblStaffProj.FY = tblRepHours.FY) AND (tblStaffProj.ProjID = tblRepHours.ProjID) AND (tblStaffProj.UserID = tblRepHours.USERID)) ON tblStaff.USERID = tblStaffProj.UserID;
    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
    sockswithsandals is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2012
    Posts
    7
    Thanks a lot! That got me a lot further. One thing though, now the query shows every weekly report as a separate line for project so it has one project 4 times per every period. Would it be possible to have reported hours totals per project per period in the results...?

    Like if I have

    SELECT tblRepHours.userid, tblRepHours.projid, tblRepHours.fy, tblRepHours.rhperiod, Sum(tblRepHours.rephours) AS SumOfrephours
    FROM tblRepHours
    GROUP BY tblRepHours.userid, tblRepHours.projid, tblRepHours.fy, tblRepHours.rhperiod;

    then it shows totals from tblRepHours as I'd like it to show but how can I combine that with the allocations? Or should I make a new table which has reported hours totals in it...?

    BR,

    "A lot to learn from Access"

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Certainly is possible.

    Suggest you build a report that will summarize data in group header/footer sections. This will allow display of the detail records as well as summary calculations. Use the query I provided (add the APct field to the query) as the RecordSource for report. Here it is again, slightly modified:

    SELECT tblRepHours.*, tblStaffProj.APct, tblProj.ProjName, tblProj.ProjEvery, tblStaff.StaffF, tblStaff.StaffL, tblStaff.StaffT, tblStaff.StaffR
    FROM tblStaff RIGHT JOIN ((tblProj RIGHT JOIN tblStaffProj ON tblProj.ProjID = tblStaffProj.[ProjID]) RIGHT JOIN tblRepHours ON (tblStaffProj.APeriod = tblRepHours.RHPeriod) AND (tblStaffProj.FY = tblRepHours.FY) AND (tblStaffProj.ProjID = tblRepHours.ProjID) AND (tblStaffProj.UserID = tblRepHours.USERID)) ON tblStaff.USERID = tblStaffProj.UserID;

    Access Help has guidelines on building reports using Grouping & Sorting with aggregate calcs. Also, review:
    http://office.microsoft.com/en-us/ac...010341571.aspx
    http://office.microsoft.com/en-us/ac...aspx?section=5
    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.

  5. #5
    sockswithsandals is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2012
    Posts
    7
    Thanks a lot again! I think this can be marked as solved.

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

Similar Threads

  1. connecting two tables?
    By imintrouble in forum Access
    Replies: 1
    Last Post: 01-24-2012, 02:22 PM
  2. Replies: 3
    Last Post: 01-06-2012, 03:30 PM
  3. problem while saving database design
    By Ramya in forum Database Design
    Replies: 1
    Last Post: 08-02-2011, 07:39 AM
  4. Database design - connecting 2 tables
    By Eisaz in forum Database Design
    Replies: 2
    Last Post: 10-16-2009, 09:19 AM
  5. Database Design Problem
    By Kurth in forum Access
    Replies: 0
    Last Post: 08-14-2008, 04:09 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