Results 1 to 10 of 10
  1. #1
    MTSPEER is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    283

    InStr Update Query

    Hello,

    I am wondering why this update query won't work for me?

    UPDATE Producer_World SET Producer_World.Body = " "


    WHERE (((Producer_World.Body)=Left([Body],InStr([Body],"Date Request"))));


    Thanks

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    does the SELECT query return values based on:
    WHERE (((Producer_World.Body)=Left([Body],InStr([Body],"Date Request"))));

    if not, nor will the update query.

  3. #3
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Perhaps you could explain exactly what it is supposed to do and post some of your data?

  4. #4
    MTSPEER is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    283
    Yes it does. It returns everything left of "Date Request"

  5. #5
    MTSPEER is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    283
    I want it to delete everything left of "Date Request" in the field "Body"

  6. #6
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I am confused by your criteria.
    You are comparing the Body field to itself?
    I think we really need to see some examples of what you data looks like, and what you want your expected result to look like.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Your SQL is attempting to set Body to a single space if string contains "Date Request", perhaps you meant an empty string?

    UPDATE Producer_World SET Producer_World.Body = "" WHERE InStr([Body], "Date Request")>0;

    I don't allow empty string in fields. I would set to Null.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I want it to delete everything left of "Date Request" in the field "Body"
    Your SET statement is setting it equal to a single space, not cutting part of the string out.

    If you truly just wanted to drop everything before the phrase "Date Request", try this:
    Code:
    UPDATE Producer_World SET Producer_World.Body = Mid([Body],InStr([Body],"Date Request"),Len([Body]))
    WHERE (((InStr([Body],"Date Request"))>0));

  9. #9
    MTSPEER is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    283
    JoeM you da man! That worked! Thanks!

  10. #10
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You are welcome.

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

Similar Threads

  1. Replies: 2
    Last Post: 04-07-2016, 07:19 AM
  2. Replies: 7
    Last Post: 03-30-2016, 07:39 PM
  3. Left instr help
    By tmcrouse in forum Forms
    Replies: 2
    Last Post: 05-12-2015, 08:47 AM
  4. IIF with instr
    By yoili in forum Reports
    Replies: 2
    Last Post: 01-22-2013, 01:32 PM
  5. Using InStr() inside Mid()
    By urbi in forum Programming
    Replies: 12
    Last Post: 06-06-2012, 12:00 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