Results 1 to 3 of 3
  1. #1
    Joyce Carney is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    2

    Using If statements

    I am not sure if this is the approach I should use. I do not want to have a user put in a parameter. The first thing I want to do is to create a field named "New Campaign". I have 2 fields that I want to look at: Campaign and Lead Campaign. The If statement would be Iif(Lead Campaign = "Routing Campaign", Campaign, Lead Campaign). The other thing I want to do is count the number of ids in a field named payment type. If the id is "1" then it is cash, if it is "2" then it is credit card. I want a field for each and the count. I am doing a group by on the "New Campaign"

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I assume you're talking about a query so you have a field with this formula:

    NewCampaign: iif([Lead Campaign] = "Routing Campaign", [Campaign], [Lead Campaign])

    Where [Campaign] and [Lead Campaign] are both fields on your table.
    You have to encapsulate your field names in square brackets if they contain any special characters or spaces.
    This is also assuming you are storing a text value in your "Lead Campaign" field instead of a foreign key to a table (autonumber PK to number FK)

    For your transaction types you would have a formulae

    CashTransactions: iif([PaymentType] = 1, 1, 0)
    CardTransactions: iif([PaymentType] = 2, 1, 0)

    You would have to use an aggregate query and use SUM in the TOTALS row of your query to get the overall count of cash/card transactions.

  3. #3
    Joyce Carney is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    2
    Thanks this helped

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

Similar Threads

  1. IIF() statements
    By ajetrumpet in forum Tutorials
    Replies: 0
    Last Post: 06-17-2011, 06:51 PM
  2. If statements
    By swagger18 in forum Programming
    Replies: 6
    Last Post: 01-28-2011, 08:13 PM
  3. IIF statements?
    By staceyo in forum Queries
    Replies: 15
    Last Post: 09-28-2010, 08:45 AM
  4. SQL statements from VBA
    By John Southern in forum Programming
    Replies: 12
    Last Post: 05-16-2010, 01:07 PM
  5. If statements
    By Ezeecopy in forum Access
    Replies: 0
    Last Post: 03-24-2009, 04:54 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