Results 1 to 4 of 4
  1. #1
    Evdokimos is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2012
    Location
    CYPRUS
    Posts
    2

    A problem with a query with related tables

    Hi all
    I have a difficult problem and I will use a simplified example to explain you. I have 3 tables. TABLE1 contains the name of the sales person (SALESMANNAME), the date (WORKINGDATE) and the Hours worked (HOURSWORKED). So a combination of name and date is unique eg George and 15/6/2012 cannot be found again in another record of the table. In TABLE2 contains the sales of the particular salesman at at particular date (SALESVALUE) and has also the two key fields of TABLE1 ie SALESMANNAME and WORKINGDATE. However SALESVALUE can be found in more than once (for a particular name at a particular date). Similarly TABLE3 contains the receipts of each sales man (RECEIPSVALUE) which also can be found in more than once and two fields of table 1 (WORKINGDATE and WORKINGDATE). I want to create a query to show for a particular salesman at a particular date the hours worked, total sales and total receipts. I used the query found in the file attached but it does not produce correct result. If for example I have two records of SALESVALUE (in a particular date for a particular name) and one record RECEIPSVALUE, the RECEIPSVALUE is double the correct amount.
    Please note that I want to avoid a solution of using subqueries or changing the relationship of the tables (eg one to many) since I want the solution to be applied to the specific query. This is because I want to derive a query statement to be used in an Excel macro. Also the structure of tables cannot be changed.
    I thank you in advanced for your kind help

    Hi all append.doc

    Evdokimos

  2. #2
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Till someone comes along,
    Am not familiar with excel macros, all the same :
    Is it not possible to design a query with sub-queries in your Access db.
    Then, in the excel, Under the "Data" menu, selecting "From Access", etc.
    Does this not work ?

    Thanks

  3. #3
    Evdokimos is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2012
    Location
    CYPRUS
    Posts
    2
    Thanks a lot for your answer.

    However this cannot work for my case.

  4. #4
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Quote Originally Posted by Evdokimos View Post
    However this cannot work for my case.
    Though you have not mentioned, why it does not work, I am assuming, it is perhaps because of the parameter in the Query.
    If that is the case, just check out if below gives some guidelines (Somewhere near the middle - Using Parameters In External ODBC Data Queries) :

    http://www.nickhodge.co.uk/pre2007/g...taexamples.htm

    Thanks

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

Similar Threads

  1. One Form to Update 2 Related Tables?
    By zannix in forum Forms
    Replies: 3
    Last Post: 01-26-2012, 08:46 AM
  2. Query on related tables question
    By jpkeller55 in forum Access
    Replies: 12
    Last Post: 09-28-2010, 07:18 PM
  3. Query with related tables question
    By jpkeller55 in forum Access
    Replies: 4
    Last Post: 09-25-2010, 04:29 AM
  4. Not able to make Form from related Tables
    By a1y1a1y1 in forum Forms
    Replies: 5
    Last Post: 01-02-2010, 12:33 PM
  5. 3 Related Dependent Tables
    By jbarrum in forum Access
    Replies: 0
    Last Post: 11-17-2009, 11: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