Results 1 to 8 of 8
  1. #1
    Reaper is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Nov 2011
    Posts
    57

    Update Query problem


    Why doesn't this line of code work?

    DoCmd.RunSQL ("UPDATE tbltransactions SET tbltransactions.ynTicketConsumed = true WHERE tbltransactions.strticket = varTicketValue")

    It opens an Inputbox asking for the value of "varTicketValue".

    "varTicketValue" is declared Public as Variant and then is set just prior to running the SQL. I have verified that the variable is being properly set displaying it in a text box. If I input the proper value the Update query works correctly.

  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481
    Maybe you need brackets around varTicketValue to mark it as a control???
    [varTicketValue]

  3. #3
    Join Date
    Nov 2011
    Location
    Hamilton, NZ
    Posts
    18
    did you bebug and check ?

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    DoCmd.RunSQL ("UPDATE tbltransactions SET ynTicketConsumed = true WHERE strticket ='" & varTicketValue & "'")

    This is assuming that strticket is text datatype (so quotes around the value are required)

  5. #5
    Reaper is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Nov 2011
    Posts
    57
    Unfortunately it's an autonumber. Still trying to weed out the bad naming that the previous programmer left me. So drop the quotes?

  6. #6
    Join Date
    Nov 2011
    Location
    Hamilton, NZ
    Posts
    18
    DoCmd.RunSQL ("UPDATE tbltransactions SET tbltransactions.ynTicketConsumed = true WHERE tbltransactions.strticket = "& varTicketValue &"")

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Quote Originally Posted by Reaper View Post
    Unfortunately it's an autonumber. Still trying to weed out the bad naming that the previous programmer left me. So drop the quotes?
    If strticket is number datatype, then just drop the quotes

    DoCmd.RunSQL ("UPDATE tbltransactions SET ynTicketConsumed = true WHERE strticket =" & varTicketValue )

  8. #8
    Reaper is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Nov 2011
    Posts
    57
    Works great. Thanks.

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

Similar Threads

  1. double update query problem
    By tss in forum Queries
    Replies: 9
    Last Post: 11-04-2011, 08:50 AM
  2. Update query size problem?
    By Akshay22 in forum Queries
    Replies: 1
    Last Post: 10-26-2011, 01:02 PM
  3. Update query problem
    By pratim09 in forum Queries
    Replies: 5
    Last Post: 05-05-2011, 06:05 AM
  4. Problem with Update Query?
    By emarchant in forum Access
    Replies: 7
    Last Post: 10-08-2010, 12:51 PM
  5. Update Query problem
    By sollem1 in forum Queries
    Replies: 0
    Last Post: 11-08-2007, 10:16 AM

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