Results 1 to 8 of 8
  1. #1
    guyfromstl is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    4

    Query - Use the same field to populate additional fields

    Hello,



    I have a rather complex query where I need to populate ticket fees into two columns. The first column I want to return all ticket fees that are divisible by $12.00, and the second column I want to return all ticket fees that are divisible by $13.50. I thought I could use the field ticket fee twice and for the criteria use "like 12 or 24" for $12 values and use "like 13.50 or 27.00" for the $13.50 values. I also tried iif statements and both were unsuccessful. I am trying to determine the best way without having to revamp the query or make it more complex than necessary.

    Thank you.

  2. #2
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    You may want to look at the Mod() function.
    Test for 0 returned number.

    iif(mod(ticket/12)>0,Truesomething,iif(Mod(ticket/13.5)>0, TRUEsomething,FalseSomething))


    Dale

  3. #3
    guyfromstl is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    4
    How would this work to have this same expression in two different fields so when I run the query I see two columns (one with $12's and one with $13.50's)

  4. #4
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    Add the field twice.
    One field
    Twelve:Iif(Mod(Field/12)>0,true,false)
    Other field
    Thirteen:Iif(Mod(Field/13.5)>0 , true,False)

    Dale

  5. #5
    guyfromstl is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    4
    The following is the syntax I used:
    Twelve:Iif(Mod([ticket_fee_2]/12)>0,[ticket_fee_2],0
    I get a popup box saying the expression you entered contains invalid syntax. You may have entered a comma without a preceding value or identifier.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Will all data be divisible evenly by either 12 or 13.50?

    Try:

    Column1: IIf([fieldname] Mod 12 = 0, [fieldname], Null)

    Column2: IIf([fieldname] Mod 12 = 0, Null, [fieldname])
    OR
    Column2: IIf([fieldname] * 100 Mod 13.50 * 100 = 0, [fieldname], Null)
    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
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    Good grief Dale.
    Thanks June7.
    I was thinking more about how to get the problem solved than the syntax.

    Sorry guy for the error in syntax for Mod().
    Thanks again june7 for straightening me and the problem out.

    Dale

  8. #8
    guyfromstl is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    4
    Thanks all for your help. This works perfectly. Time for me to do some research on the Mod() function.

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

Similar Threads

  1. Replies: 1
    Last Post: 06-11-2012, 02:34 PM
  2. Replies: 4
    Last Post: 01-30-2012, 08:32 AM
  3. Additional field in a query
    By Berend Lindeman in forum Queries
    Replies: 2
    Last Post: 01-03-2012, 03:25 PM
  4. Fields populate based on another field
    By jlclark4 in forum Forms
    Replies: 3
    Last Post: 12-27-2011, 05:21 PM
  5. Populate one field based upon another fields data
    By BigBrownBear in forum Queries
    Replies: 1
    Last Post: 03-23-2010, 04:27 PM

Tags for this Thread

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