Results 1 to 5 of 5
  1. #1
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    528

    How to Collect two fields from two different places

    Hello Guys


    I have a form that contains two subform
    In the subform No. 1 there is a currency field
    In the subform No. 2 there is a currency field
    The question is
    I want a model that combines independent currency field in a subform 1 and 2
    And I will show queries of the subforms

    subform No. 1
    SELECT tblGoodsPurchased.GoodsPurchesedID, tblGoodsPurchased.OrderDateID, tblGoodsPurchased.GoodsID, tblGoodsPurchased.Qty, tblGoodsPurchased.Price, tblGoodsPurchased.Calibre, tblGoodsPurchased.WagWork, tblGoodsPurchased.Other, [Price]*[Qty]+[WagWork] AS Expr1, tblGoodsPurchased.Paid, [Expr1]-[Paid] AS Expr2
    FROM tblGoodsPurchased;
    -------------------------------------------------------------------------
    subform No. 2
    SELECT tblGroups.GroID, tblGroups.OrderdateID, tblGroups.TypeofSilverID, tblGroups.Mykmea, tblGroups.Calibre, tblGroups.Ounce, tblGroups.WagWork, tblGroups.Other, tblGroups.rebate, ([Ounce]/31.1) AS IOunce, [IOunce]*[Calibre] AS Igram, [WagWork]*[Mykmea] AS Expr2, [WagWork]+[Igram] AS IgmAndwag, ([IgmAndwag]*[mykmea]) AS Total, tblGroups.Paid, [totalAmount]-[Mykmea] AS mtbke, [Total]-[Paid] AS Expr1
    FROM NamSelvir RIGHT JOIN tblGroups ON NamSelvir.ID = tblGroups.TypeofSilverID;

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,849

  3. #3
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    528
    Thank you very much
    But this is not what I want
    What I want is
    Collection of fields query 1 query with fields of 2
    But show me a message
    Click image for larger version. 

Name:	3666.JPG 
Views:	10 
Size:	18.0 KB 
ID:	15118

    SELECT tblGoodsPurchased.GoodsPurchesedID, tblGoodsPurchased.OrderDateID, tblGoodsPurchased.GoodsID, tblGoodsPurchased.Qty, tblGoodsPurchased.Price, tblGoodsPurchased.Calibre, tblGoodsPurchased.WagWork, tblGoodsPurchased.Other, [Price]*[Qty]+[WagWork] AS Expr1, tblGoodsPurchased.Paid, [Expr1]-[Paid] AS Expr2
    FROM tblGoodsPurchased;

    UNION ALL SELECT tblGroups.GroID, tblGroups.OrderdateID, tblGroups.TypeofSilverID, tblGroups.Mykmea, tblGroups.Calibre, tblGroups.Ounce, tblGroups.WagWork, tblGroups.Other, tblGroups.rebate, ([Ounce]/31.1) AS IOunce, [IOunce]*[Calibre] AS Igram, [WagWork]*[Mykmea] AS Expr2, [WagWork]+[Igram] AS IgmAndwag, ([IgmAndwag]*[mykmea]) AS Total, tblGroups.Paid, [totalAmount]-[Mykmea] AS mtbke, [Total]-[Paid] AS Expr1
    FROM NamSelvir RIGHT JOIN tblGroups ON NamSelvir.ID = tblGroups.TypeofSilverID;

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,849
    The message is clear - the number of columns in the the selected tables of the UNION query do not match.

    The ALL will include any duplicates.

    see http://www.techonthenet.com/sql/union.php

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    I count 11 fields in the first SELECT and 17 in the second.

    The first SELECT line defines the field names so the aliases are ignored and not needed in the following SELECT lines. Use alias in the first SELECT.

    Use Null as placeholder where there is not a corresponding field in one of the SELECT lines. For instance, not seeing the equivalent of TypeofSilverID in the first SELECT so put Null in the same position with field alias:

    , Null AS TypeOfSilverID,
    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. Collect certain values
    By azhar2006 in forum Reports
    Replies: 7
    Last Post: 01-03-2014, 04:52 PM
  2. collect data via email
    By aspen in forum Access
    Replies: 2
    Last Post: 04-26-2012, 03:21 AM
  3. Collect a certain value
    By alwazeer in forum Reports
    Replies: 3
    Last Post: 11-17-2011, 04:20 PM
  4. Best Way to Collect Data
    By dssrun in forum Access
    Replies: 9
    Last Post: 01-05-2011, 10:14 AM
  5. many decimal places in calculated fields
    By GordS in forum Access
    Replies: 1
    Last Post: 02-04-2009, 11: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