SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Updating the Yes/No checkbox in Access with ASP

    I can read the values of the checkbox by using the following statement

    [vbs]
    rs("InFlyer") = "True"
    [/vbs]

    But for the life of me I cant update the table to check or uncheck the box.

    Here's my code:

    [vbs]
    Set rs = Server.CreateObject("ADODB.Recordset")
    sql = "UPDATE Flyer SET InFlyer = 'True' WHERE ((Brand = '" & brand & "') AND (category = '" & category & "') AND (ShoeSize = '" & ShoeSize & "') AND (ShoeColor = '" & ShoeColor & "'));"
    rs.Open sql, conn
    [/vbs]

    The query goes thru with no errors, but the checkbox isn't checked when I open the table.

  2. #2
    SitePoint Wizard
    Join Date
    Jan 2001
    Location
    Milton Keynes, UK
    Posts
    1,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't use the quotes with the Boolean variable.

    If this is Access then I think that Yes/No, 1/0 and True/False will work.
    Last edited by shane; Mar 25, 2002 at 04:13.

  3. #3
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried it without the single quotes and it's not updating. Any other ideas?

    I tried True, Yes and 1. None of these works.

    When I check it in the start page, I am using this code:

    [vbs]
    <% if rs("InFlyer") = "True" then response.Write(" checked")%>
    [/vbs]

    Seems weird that I can't use the same to update the record.

  4. #4
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I found my problem. When I am testing the Check box value, it is passing the variable as "on". I was checking for a different value.

  5. #5
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's definitely working now with no quotes on the True

  6. #6
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For Boolean values, true=yes=on, and false=no=off. The field option in Access of which to display only affects the way Access renders the field value. The value in the field is unaffected, and will accept any of the above.

    'True' would have been a string (and you can't set boolean fields to equal strings), but True is the actual boolean value, so that is why it now works!

    (you probably know this already, just making it clear for others too)


    M@rco

  7. #7
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not 100% sure why your check was working though! Probably because VBScript variables being variants, so are automatically converted for comparisons and other operations.


    M@rco


Bookmarks

Posting Permissions

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