Turning true and false to yes and no

Results 1 to 8 of 8

Thread: Turning true and false to yes and no

  1. #1
    Join Date
    Dec 1969
    Posts
    1,671

    Default Turning true and false to yes and no

    When I get the results of a query that returns a yes/no field from access i get "true" or "false" in my table. How can i turn this into a "Yes" or "No". I&#039m no good at VB script but is it like this.<BR><BR>RS("Approved") is the recordset that contains "true" or "false"<BR><BR>if RS("Approved") = "True" then<BR>Set App = "Yes"<BR>else<BR>Set App = "No"<BR>end if <BR><BR>and then will "App" will equal Yes or No?<BR><BR>Any help would be greatly appreciated

  2. #2
    Steve Cimino Guest

    Default Close, but no set

    Don&#039t use set for this. You technically could do:<BR><BR>Let App = "Yes"<BR><BR>But it&#039s more standardized just to do<BR><BR>App = "yes"

  3. #3
    Join Date
    Dec 1969
    Posts
    626

    Default RE: Close, but no set

    I Don&#039t think you need quotes around True or even True at all...<BR><BR>if rs("BooleanField") Then<BR>&#039True<BR>Else<BR>&#039False<BR>End<BR> <BR>Correct??<BR><BR><BR>

  4. #4
    Join Date
    Dec 1969
    Location
    Los Angeles, CA
    Posts
    21,192

    Default It will work BUT

    &#062;RS("Approved") is the recordset that contains "true" or "false"<BR><BR>&#062;if RS("Approved") = "True" then<BR>&#062;Set App = "Yes"<BR>&#062;else<BR>&#062;Set App = "No"<BR>&#062;end if <BR><BR>get rid of the Set <BR><BR>then if it returns "true" you HAVE TO compare with "true" not "True" check that case


  5. #5
    Steve Cimino Guest

    Default RE: Close, but no set

    No, you don&#039t, and I prefer not to use boolean values with the true or false words.. I think it reads easier If myvar for true, or If Not myvar for false, but there isn&#039t anything wrong with what he has. You can use either "true" or True (no quotes) for these checks (it&#039s been awhile since I&#039ve done it that way, so don&#039t shoot me if I&#039m wrong).

  6. #6
    Join Date
    Dec 1969
    Posts
    1,671

    Default RE: It will work BUT

    Now they all say "No" even if they are "true".<BR>What am I doing wrong?<BR><BR>if RS("Approved") = "True" then<BR>App = "Yes"<BR>else<BR>App = "No"<BR>end if <BR><BR>Many thanks<BR><BR>Mike

  7. #7
    Steve Cimino Guest

    Default RE: It will work BUT

    If it is a yes/no field in access, don&#039t ask if it is = to true.<BR><BR>Just do If RS("Approved") Then &#039This is the same as true<BR><BR>If it is a string, watch your case. It&#039s better to do this if you&#039re not sure<BR><BR>If UCase(RS("Approved")) = "TRUE" Then

  8. #8
    Join Date
    Dec 1969
    Posts
    1,671

    Default Thanks Guys!

    It also helps if you put it in the loop!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •