Results 1 to 11 of 11
  1. #1
    Koloss is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2013
    Posts
    14

    problem by subtracting the two queries

    I have the following problem:


    I have two tables. In the first (Baza) are:

    ID
    Mag_sifra
    Int_Mag_Sifra
    Naziv
    Kolicina
    Datum

    In the second (Izdato) are:

    ID
    Mag_Sifra
    Int_Mag_Sifra
    Naziv
    Izdato
    Datum

    Values Mag_Sifra, Naziv is the same in the both table. I made two queries. Query Baza and query Izdato. I want substract kolicina from first and Izdato from second. I get the following result:

    14485 133 01 44 85 MANZETNA F-55/F 0 160 -160
    14485 144 01 44 85 MANZETNA F-55/F 160 160 0

    But i want this:

    14485 133 01 44 85 MANZETNA F-55/F 0 0 0
    14485 144 01 44 85 MANZETNA F-55/F 160 160 0

    Wher is 14485- Mag_Sifra, 133 01 44 85 and 144 01 44 85 - Int_Mag_Sifra, MANZETNA F-55/F - Naziv, first number is kolicina, second is izdato, and third is result.

    I'm sorry cos my bad english and i houp you understand me.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Can't you just build one query that joins the two tables linking on the two key fields?
    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
    Koloss is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2013
    Posts
    14
    I try, but i get same result. Click image for larger version. 

Name:	untitled2.JPG 
Views:	4 
Size:	65.6 KB 
ID:	11089

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I can see now that should probably do two aggregate queries and then join those queries. The issue seems to be the Int_Mag_Sifra field. What is relationship of these tables? Why is Int_Mag_Sifra in both tables but it is not always the same value in both? Should this field be exluded when grouping data?
    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
    Koloss is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2013
    Posts
    14
    Int_Mag_Šifra is the code of the place where the goods are in the warehouse. Its location. Mag_Šifra is the commodity code. Kolicina is the quantity of input goods, Izdato is the goods which have been issued.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Do you care about location for this output? Sounds like it should be excluded when grouping records to sum Kolicina and Izdata. Don't include Int_Mag_Šifra in the queries and see what happens.
    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.

  7. #7
    Koloss is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2013
    Posts
    14
    It's the same result... Click image for larger version. 

Name:	untitled3.JPG 
Views:	4 
Size:	57.8 KB 
ID:	11090

  8. #8
    Koloss is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2013
    Posts
    14
    Maybe i try create a second table with completely different names. And then to link it to the first.

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Sorry, really don't know your data structure well enough. Would have to work with the database.
    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.

  10. #10
    Koloss is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2013
    Posts
    14
    Maybe this examle can help, cos i dont see solution.
    Attached Files Attached Files

  11. #11
    Koloss is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2013
    Posts
    14

    Thumbs up Solved

    I solved the problem. The problem was formatting Int_Mag_Šifra field, which was formatted as text. In order not to re-enter all the data, I created two new query and use the Val function for the Int_Mag_Sifra field. Now it works perfectly. Thanks to everyone who tried to help me.
    Last edited by Koloss; 02-15-2013 at 03:46 AM. Reason: Solved

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

Similar Threads

  1. Subtracting Dates in Queries
    By seanpbent in forum Access
    Replies: 1
    Last Post: 02-01-2013, 04:28 PM
  2. Iif and calculated queries problem
    By erringtonl in forum Queries
    Replies: 1
    Last Post: 01-20-2012, 02:20 PM
  3. Adding/Subtracting
    By JayX in forum Access
    Replies: 1
    Last Post: 12-15-2011, 01:47 PM
  4. Another problem with queries
    By Viggen66 in forum Queries
    Replies: 3
    Last Post: 02-23-2010, 05:01 PM
  5. Queries to Form Problem
    By PnerraD in forum Queries
    Replies: 1
    Last Post: 06-10-2006, 09:13 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