Results 1 to 3 of 3
  1. #1
    ShostyFan is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    76

    sql in vba to update record WHERE

    I have two lines, this one works great:
    WHERE [ProductCode]='" & Me.cmboNames & "'"

    This one does not work:
    WHERE [WorkOrderNumber]='" & Me.cmboNames & "'"



    The only difference I can see is that [ProductCode] is of dataType Text and [WorkOrderNumber] is of dataType Number

    Could this be causing the problem? If so what is the fix?
    Thanks.

  2. #2
    ShostyFan is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    76
    fixed it, sorry for the premature post.
    when you have different data types you must put LIKE instead of = after the WHERE
    so:
    WHERE [WorkOrderNumber]='" & Me.cmboNames & "'"
    was fixed by
    WHERE [WorkOrderNumber] LIKE '" & Me.cmboNames & "'"

  3. #3
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Not really. When it's text it has to be delimited with single or double quotes (how depends on the situation). If date data type, octothorpes (#) if numeric data type, nothing. That is the correct method for this. LIKE is using pattern matching, which in this case is a kind of hack.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 9
    Last Post: 12-08-2021, 02:40 AM
  2. Replies: 2
    Last Post: 02-28-2019, 03:49 PM
  3. Update Table after Record Update with Form
    By speciman_A in forum Forms
    Replies: 25
    Last Post: 10-31-2014, 01:00 PM
  4. Replies: 14
    Last Post: 08-12-2014, 06:33 AM
  5. Replies: 4
    Last Post: 12-14-2012, 06:33 PM

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