Results 1 to 6 of 6
  1. #1
    elender is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2017
    Posts
    5

    Alernative to SWITCH function???

    I am building a query for survey data and I want to assign a numeric value to the answers of the survey questions.
    The key is that the same answers indicate different amounts of "points" depending on the question. In other words, Yes might =1 sometimes but not others.



    For example:
    Question 1: Are you satisfied with your life? Yes= 1pt, More or Less=1pt, No=0 pts
    Question 2: Do you feel full of energy? No=1 pt, More or Less=0pts Yes= 0 pts

    I wrote in the SWITCH function originally (example below)
    SWITCH([Q1]=Yes,1,[Q1]="More or Less",1,[Q1]=No,0)

    But alas, it is working for some columns and not others. In expression column I wrote in the proper point system for the corresponding question, but still no luck. I also tried the IIF function which also didn't work.

    Is there an alternative way to accomplish this? Is my expression incorrect?

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Store them on the table with the questions, 3 separate points fields, then select the one corresponding to the answer.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    1. a lookup table to join in the query to exchange results
    2, a Case statment in a custom function
    3, IIF statment in the query

  4. #4
    elender is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2017
    Posts
    5
    Quote Originally Posted by ranman256 View Post
    1. a lookup table to join in the query to exchange results
    2, a Case statment in a custom function
    3, IIF statment in the query



    Hi,
    Can you elaborate on #3? I am fairly new to Access, but below is the IIF statement I tried and it did not return any results:

    =IIf([LS1]="Yes",1,IIf[LS1]="No",0)

  5. #5
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    =IIf([LS1]="Yes",1,0)

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    your code does not make sense

    SWITCH([Q1]=Yes,1,[Q1]="More or Less",1,[Q1]=No,0)

    ([Q1]=Yes and [Q1]=No implies Q1 is a Boolean field (i.e. a yes/no field)

    [Q1]="More or Less" implies Q1 is a text field

    it can't be both

    [LS1]="Yes" and [LS1]="No" implies LS1 is text

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

Similar Threads

  1. Switch function in query design view
    By sichilaba in forum Forms
    Replies: 6
    Last Post: 12-09-2014, 10:20 AM
  2. Exporting A Query containing a SWITCH function - unable....
    By MissAran in forum Import/Export Data
    Replies: 2
    Last Post: 02-25-2014, 11:05 PM
  3. Using SQL switch function MS Access
    By sandlucky in forum Queries
    Replies: 18
    Last Post: 03-31-2011, 08:49 AM
  4. Select Query in Switch Function
    By sandlucky in forum Queries
    Replies: 0
    Last Post: 03-30-2011, 04:54 AM
  5. Combine switch function and Wild cards together
    By sandlucky in forum Queries
    Replies: 0
    Last Post: 03-28-2011, 11:51 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