Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. sql statement in microsoft access to include IIF statement

sql statement in microsoft access to include IIF statement

Scheduled Pinned Locked Moved Database
database
8 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    johnnysmith1
    wrote on last edited by
    #1

    Hello, I have table in microsoft access with fields- partNumber, Date, Status. ( the status field always is one of two words - on or off can I write a iif statement in sql that says IIf ([partNumber = a certain Date]), the status will automatically display off for those records with that part number. I already have alot of records entered in database. I have tried and not used to writing IIf statements in sql- also wonder can you change a field that has data in it with a iif condition statement. thank you

    B 1 Reply Last reply
    0
    • J johnnysmith1

      Hello, I have table in microsoft access with fields- partNumber, Date, Status. ( the status field always is one of two words - on or off can I write a iif statement in sql that says IIf ([partNumber = a certain Date]), the status will automatically display off for those records with that part number. I already have alot of records entered in database. I have tried and not used to writing IIf statements in sql- also wonder can you change a field that has data in it with a iif condition statement. thank you

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      As I understand you then you want to display Status to OFF for some records which contain one certain data in field Date ?


      I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

      modified on Saturday, June 6, 2009 5:12 PM

      J 1 Reply Last reply
      0
      • B Blue_Boy

        As I understand you then you want to display Status to OFF for some records which contain one certain data in field Date ?


        I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

        modified on Saturday, June 6, 2009 5:12 PM

        J Offline
        J Offline
        johnnysmith1
        wrote on last edited by
        #3

        yes you are correct

        B 1 Reply Last reply
        0
        • J johnnysmith1

          yes you are correct

          B Offline
          B Offline
          Blue_Boy
          wrote on last edited by
          #4

          here it is

          select iif(value='2009.01.02','OFF',value) from table1


          I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

          J 1 Reply Last reply
          0
          • B Blue_Boy

            here it is

            select iif(value='2009.01.02','OFF',value) from table1


            I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

            J Offline
            J Offline
            johnnysmith1
            wrote on last edited by
            #5

            unfortunately this did not solve problem I have partNumber Date and Status I have tried Select partNumber,Date IIF(partNumber= 1011 and Date = #01/01/2006#,"OFF,ON) From table1 but still gettng errors-your sql statement is missing partNumber thank you

            modified on Sunday, June 7, 2009 7:34 AM

            B 1 Reply Last reply
            0
            • J johnnysmith1

              unfortunately this did not solve problem I have partNumber Date and Status I have tried Select partNumber,Date IIF(partNumber= 1011 and Date = #01/01/2006#,"OFF,ON) From table1 but still gettng errors-your sql statement is missing partNumber thank you

              modified on Sunday, June 7, 2009 7:34 AM

              B Offline
              B Offline
              Blue_Boy
              wrote on last edited by
              #6

              johnnysmith1 wrote:

              Date IIF(partNumber= 1011 and Date = #01/01/2006#,"OFF,ON)

              Should be

              Date , IIF(partNumber= 1011 and Date = #01/01/2006#,'OFF','ON')


              I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

              J 1 Reply Last reply
              0
              • B Blue_Boy

                johnnysmith1 wrote:

                Date IIF(partNumber= 1011 and Date = #01/01/2006#,"OFF,ON)

                Should be

                Date , IIF(partNumber= 1011 and Date = #01/01/2006#,'OFF','ON')


                I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

                J Offline
                J Offline
                johnnysmith1
                wrote on last edited by
                #7

                thank you it works

                B 1 Reply Last reply
                0
                • J johnnysmith1

                  thank you it works

                  B Offline
                  B Offline
                  Blue_Boy
                  wrote on last edited by
                  #8

                  You are welcome.


                  I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups