finding value for check box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NasirMunir
    New Member
    • Jun 2007
    • 27

    finding value for check box

    I need some help in figuring out how to return the value of a check box. I am trying to migrate data from access to sql server 2000. One of my access table contains check box option: a user can select or it is not selected. The problem is that sql server takes that field as null.
    Now I am trying to get the value of the check box; something like "0" if not checked and "1" or "-1" if checked. If I can translate to some value, then I am fine with that and can store the same values in sql server.
    In order to do that I am trying to use expression builder (IIF function), however, can't seem to figure out how to use an expression to relate check or uncheck option.
    Can anyone help me in this regard ?
    Thanks
  • JKing
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    For the yes/no field 0 = no or false and -1 = yes or true. A quick fix I can think of is simply changing the field data type from Yes/No to Number. This should convert any records with the field checked to -1 and any unchecked to 0. Make sure to backup and save before attempting this.

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      Originally posted by NasirMunir
      I need some help in figuring out how to return the value of a check box. I am trying to migrate data from access to sql server 2000. One of my access table contains check box option: a user can select or it is not selected. The problem is that sql server takes that field as null.
      Now I am trying to get the value of the check box; something like "0" if not checked and "1" or "-1" if checked. If I can translate to some value, then I am fine with that and can store the same values in sql server.
      In order to do that I am trying to use expression builder (IIF function), however, can't seem to figure out how to use an expression to relate check or uncheck option.
      Can anyone help me in this regard ?
      Thanks
      Try
      Code:
      iif(CheckboxFieldName, 1, 0)

      Comment

      • NasirMunir
        New Member
        • Jun 2007
        • 27

        #4
        Code:
        SOW: IIf([SOW],-1,0)
        I am still struggling with IIF statement: the error suggests the circular reference, any help ?
        "Circular reference caused by alias 'SOW' in query definition's SELECT list"

        Comment

        • NasirMunir
          New Member
          • Jun 2007
          • 27

          #5
          okay, that circular reference is settled, i used
          Code:
          SOW: IIf([Design and Qualification].[SOW],-1,0)
          but now another problem: It is displaying all as -1, i guess because it is looking at the check box field and is returning true for that.
          My problem is to find the field checked or un checked and accordingly assign -1 for checked and 0 for un checked.

          Need some help here,
          Thanks

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            Originally posted by NasirMunir
            okay, that circular reference is settled, i used
            Code:
            SOW: IIf([Design and Qualification].[SOW],-1,0)
            but now another problem: It is displaying all as -1, i guess because it is looking at the check box field and is returning true for that.
            My problem is to find the field checked or un checked and accordingly assign -1 for checked and 0 for un checked.

            Need some help here,
            Thanks
            try CheckboxName = True instead.

            Comment

            • NasirMunir
              New Member
              • Jun 2007
              • 27

              #7
              thanks a lot for the help, case is resolved.
              Actually I was using the wrong table name :), my bad. It works fine now.
              The "IIF" sttement suggested earlier is right, I was wrong.
              God Bless

              Comment

              • Rabbit
                Recognized Expert MVP
                • Jan 2007
                • 12517

                #8
                Glad you got it working, good luck.

                Comment

                Working...