Results 1 to 2 of 2
  1. #1
    yrstruly is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2024
    Posts
    122

    Add Currenc Type To Detect Automatic Currency

    I have this form that works
    Code:
     "	SELECT    TblLicence.*,
        Nz (q.Royalty, 0) AS RoyaltyCalc,
        Nz (q.CurrencyType, "") AS CurrencyType_Qry,
        Nz (q.IPOwnerShare, 0) AS IPOwnerShare,
        Nz (q.SAPOShare, 0) AS SAPOShare
    FROM
        (
            (
                TblLicence
                INNER JOIN Profile ON TblLicence.Nr = Profile.Nr
            )
            INNER JOIN Plants ON TblLicence.PlantID = Plants.PlantID
        )
        LEFT JOIN qryRoyaltyCurrencySplit AS q ON TblLicence.PlantID = q.PlantID;"
    I want to add the currency type to detect currency type automatically. I havetried serveral versions of this code and it doe not work.
    From :
    Code:
    SELECT    DISTINCTROW TblPlantsPrices.PlantID,
        TblPlantsPrices.SoldAs,
        Plants.Cultivar,
        Plants.Clone,
        Plants.Ipno,
        Plants.PlantType,
        Plants.VarietyList,
        Plants.PhytoCert,
        TblPlantsPrices.Winter,
        TblPlantsPrices.Summer,
        TblPlantsPrices.Autumn,
        TblPlantsPrices.Grape,
        TblPlantsPrices.NoSeason,
        TblPlantsPrices.Price,
        TblPlantsPrices.[Royalty/Levy],
        TblPlantsPrices.CurrencyType AS OriginalCurrencyType,
        TblPlantsPrices.[Royalty/Levy_LastYear],
        TblPlantsPrices.SummerAll,
        TblPlantsPrices.AutumnAll,
        TblPlantsPrices.WinterAll,
        TblPlantsPrices.GrapeAll,
        TblPlantsPrices.Scion,
        TblPlantsPrices.Root,
        TblPlantsPrices.KWVAll,
        TblPlantsPrices.Vat,
        TblPlantsPrices.[Other Royalties],
        TblPlantsPrices.Other_Royalties_LastYear,
        TblPlantsPrices.Royalty AS Royalty_Original,
        TblPlantsPrices.Levy,
        TblLicence.PlantBreederRights,
        IIf(
            [PlantBreederRights] = Yes,
            "Royalty",
            IIf([PlantBreederRights] = No, "Levy", "")
        ) AS RorL,
        TblPlantsPrices.ExchangeRateMonth,
        TblPlantsPrices.RLCollectedBy,
        Nz (qryRoyaltyCurrencySplit.Royalty, 0) AS Royalty,
        Nz (qryRoyaltyCurrencySplit.CurrencyType, "") AS CurrencyType,
        Nz (qryRoyaltyCurrencySplit.IPOwnerShare, 0) AS IPOwnerShare,
        Nz (qryRoyaltyCurrencySplit.SAPOShare, 0) AS SAPOShare
    FROM
        (
            (
                Plants
                INNER JOIN TblPlantsPrices ON Plants.PlantID = TblPlantsPrices.PlantID
            )
            LEFT JOIN TblLicence ON Plants.PlantID = TblLicence.PlantID
        )
    
    LEFTJOIN qryRoyaltyCurrencySplit ON Plants.PlantID = qryRoyaltyCurrencySplit.PlantID;
    I tried
    Code:
    SELECT    TblLicence.*,
        Nz(q.Royalty, 0) AS RoyaltyCalc,
        -- This subquery automatically fetches the CurrencyType from the TblPlantsPrices table for each plant.
        -- The "TOP 1" ensures that you only get one result, preventing errors if a plant has multiple price entries.
        (
            SELECT
                TOP 1 TblPlantsPrices.CurrencyType
            FROM
                TblPlantsPrices
            WHERE
                TblPlantsPrices.PlantID = TblLicence.PlantID
        ) AS CurrencyType_Automatic,
        Nz(q.IPOwnerShare, 0) AS IPOwnerShare,
        Nz(q.SAPOShare, 0) AS SAPOShare
    FROM
        (
            (
                TblLicence
                INNER JOIN Profile ON TblLicence.Nr = Profile.Nr
            )
            INNER JOIN Plants ON TblLicence.PlantID = Plants.PlantID
        )
        LEFT JOIN qryRoyaltyCurrencySplit AS q ON TblLicence.PlantID = q.PlantID;
    
    But it breaks my code.


  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,927
    Suggest provide some example data and the outcome required from that sample data as your description is not at all clear what you require

    What does ‘breaks my code’ mean?

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

Similar Threads

  1. DSum field type "Currency", Data type mismatch
    By Budatlitho in forum Programming
    Replies: 9
    Last Post: 03-13-2025, 04:45 PM
  2. Replies: 4
    Last Post: 08-27-2021, 01:50 PM
  3. Replies: 8
    Last Post: 04-21-2021, 09:44 AM
  4. Replies: 8
    Last Post: 07-29-2014, 06:41 PM
  5. Replies: 2
    Last Post: 03-23-2011, 11:43 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