Results 1 to 7 of 7
  1. #1
    vinodnair is offline Novice
    Windows 11 Access 2021
    Join Date
    Aug 2024
    Posts
    4

    Question Kindly help me write an expression in the one of the fields in my access report. I am pretty new

    I have following fields in the report


    'Item quantity required per piece' bound field- number field : Field name in the report is [QUANTITY REQUIRED]
    'unit'- text filed- bound field: (Unit can be 'GM'-for gram,'KG'- Kilogram,'PCS'- Pieces,'ML'-Milli Liter,'LIT'- Liter)- field name in the report is [QUANTITY UNIT]
    'total production': number field: bound field: field name in the report [Text45]
    Total item required for the production : Unbound : Field name in the report is [Text371]


    For field [Text371], i want to create an expression . If the product of [QUANTITY REQUIRE] and [Text45] is greater than 1000 and if the unit is 'GM' then i want [Text371]=[Text45]*[QUANITY RQUIRED]/1000 &" "&"KG"( basically i want to convert the result to Kilogram if it's more than 1000), otherwise, the result should be [Text371]=[Text45]*[QUANTITY REQUIRED] & " " & [Units] (basically if the product is not more than 1000 and the unit is not gram , i want the result to be just the product and the respective unit ) . I wrote the expression something like below, but it didn't work Could someone please help




    IFF [Text45]*[QUANITY RQUIRED]>1000 & [QUANTITY UNIT]="GM", [Text371]=[Text45]*[QUANITY RQUIRED]/1000 &" "&"KG",[Text371]=[Text45]*[QUANTITY REQUIRED] & " " & [Units]

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,569
    Try this function IIF()

    Or create your own function in VBA.

    What are you going to do when the item is liquid?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Code:
    =IIf([Text45]*[QUANITY RQUIRED]>1000 AND [QUANTITY UNIT]="GM", [Text45]*[QUANITY RQUIRED]/1000 & " KG", [Text45]*[QUANTITY REQUIRED] & " " & [Units])
    
    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.

  4. #4
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    You are on the right track and close, look at what Welch and June7 posted compared to your line. When troubleshooting syntax issues like this, try to just do 1 section at a time and see if it works, then add a 2nd argument and see if it works, etc to pinpoint where the issue is.

  5. #5
    vinodnair is offline Novice
    Windows 11 Access 2021
    Join Date
    Aug 2024
    Posts
    4
    Got it ! Thank you so much June7

  6. #6
    vinodnair is offline Novice
    Windows 11 Access 2021
    Join Date
    Aug 2024
    Posts
    4
    Understood. You're right , I will try step by step next time . Thank you so much Bulzie

  7. #7
    vinodnair is offline Novice
    Windows 11 Access 2021
    Join Date
    Aug 2024
    Posts
    4
    Thank you for your message . For the liquid items, currently we don't have any production for more than 1 L . But now I got the code , I think I can modify it and use if required in the future. Thanks again Welshgasman

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

Similar Threads

  1. Replies: 2
    Last Post: 05-09-2018, 12:51 PM
  2. Replies: 9
    Last Post: 06-28-2017, 02:40 PM
  3. Replies: 3
    Last Post: 10-07-2016, 02:03 PM
  4. Replies: 5
    Last Post: 03-13-2012, 11:53 AM
  5. Write excel expression in access
    By ktmchugh in forum Queries
    Replies: 0
    Last Post: 07-01-2009, 02:47 PM

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