Results 1 to 4 of 4
  1. #1
    iDeals is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    22

    Query Trouble - Nested Query?

    Okay so I have four tables.



    tblCustomer
    tblFeeStructure
    tblProjectDetails
    tblProjectHours

    Each customer has a different fee structure, for example:

    fkCustID | Underwriting | Documentation | Records
    .....1.............$150............... $250............ $52

    I'm trying to tie it all together so I can generate an invoice, so for example in the ProjectHours table there may be entries like this:

    ID | fkProjID | Employee | Type of Work | Billable Hours | Description
    .1........ 1 ........... Me........Underwriting............5............Spreading

    Herein lies my problem I don't know how to get the fee structure associated with the customer to carry through to the worklog (tblProjectHours). Any ideas?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    tblFeeStructure is not normalized. As it is, use DLookup() expression in query.

    So in a query that joins Customer, ProjectDetails, ProjectHours, calculate a field for the fee: DLookup([Type of Work], "tblFeeStructure", "fkCustID=" & [CustomerID])

    Assumes the values in [Type Of Work] coincide with the field names in tblFeeStructure.
    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
    iDeals is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    22
    Thank you June, will give that a shot.

    To Normalize would each fee need its own table? For some reason I cant wrap my head around this one.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    No, each fee would be a record. This means the customer ID will be in multiple records.

    I just saw another alternative.

    Join tblFeeStructure to tblCustomer in query that includes Details and Hours. Then an expression in that query:

    Switch([Type of Work]='Underwriting', [Underwriting], [Type of Work]='Documentation', [Documentation], [Type of Work]='Records', [Records])

    As you can see, if you have more fee categories, this gets more complicated.
    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. Nested IIF Query Too Complex
    By kestefon in forum Access
    Replies: 12
    Last Post: 04-07-2014, 01:07 PM
  2. Replies: 3
    Last Post: 12-09-2013, 06:57 PM
  3. Nested And/Or query
    By kagoodwin13 in forum Queries
    Replies: 2
    Last Post: 05-10-2012, 12:10 PM
  4. Nested SQL Query
    By springboardjg in forum Queries
    Replies: 5
    Last Post: 05-08-2011, 05:01 PM
  5. Another Nested IIF Query problem
    By Brian Collins in forum Queries
    Replies: 8
    Last Post: 10-22-2010, 10:12 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