+ Reply to Thread
Results 1 to 4 of 4

Thread: Update query with multiple Sets and Where conditions

  1. #1
    Registered User
    Join Date
    10-27-2010
    Location
    NC, United States
    MS-Off Ver
    2007
    Posts
    32

    Update query with multiple Sets and Where conditions

    UPDATE TestData, BusinessRules1

    SET TestData.DESTINATIONSTATE = BusinessRules1.DESTINATIONSTATE And TestData.DESTINATIONCITY=BusinessRules1.DESTINATIONCITY AND TestData.[#BUSRULE]=1

    WHERE TestData.NAMEFUNCTION=BusinessRules1.NAMEFUNCTION And TestData.CITY=BusinessRules1.CITY And TestData.ST=BusinessRules1.ST And TestData.COM4_DESC=BusinessRules1.COM4_DESC And TestData.USPORT=BusinessRules1.USPORT And TestData.FPORT=BusinessRules1.FPORT And TestData.ULTPORT=BusinessRules1.ULTPORT And TestData.SLINE=BusinessRules1.SLINE;


    I don't receive any errors when saving this query. But when I run it, it doesn't pick up any rows to update as it should based on previous VLOOKUPs in excel with the same data. My guess is there are [s or (s I should be including.

  2. #2
    Valued Forum Contributor alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Lake County, Illinois
    MS-Off Ver
    MS Office 2010, 2007 and 2002
    Posts
    1,161

    Re: Update query with multiple Sets and Where conditions

    As a general rule, I like to build my queries in the QBE. Test them and then if I need to run them through VBA, then I copy and paste the SQL statement into code. Having said all that, have you run these queries from the QBE? If yes, did you get expected results. Also, before making a query an update query, I usually run it as a select query, so that I can see what is found before updating. An important bit of advise, if you are not doing this, is make a copy of the original table and save it as a back up so that if your updates are wrong in test you can replace the table quickly. It would be helpful also, if you were to post your db, so that we could look and see what other factors are affecting what you are attempting to do. Make sure to post it with only dummy (non-confidential) data. Also, if you have been doing lots of form and table changes, do a compact and repair prior to uploading.

    I apologize if it seems like I am ranting here.

    Alan

  3. #3
    Registered User
    Join Date
    10-27-2010
    Location
    NC, United States
    MS-Off Ver
    2007
    Posts
    32

    Re: Update query with multiple Sets and Where conditions

    Just figured it out.

    Thanks for the advice. I should have probably went the SELECT route first to make sure it was picking up matches. There was an space before my STs values. I had to delimit this from one huge field and in the process didn't catch the space. That was cause it not to pick up the matches.

  4. #4
    Valued Forum Contributor alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Lake County, Illinois
    MS-Off Ver
    MS Office 2010, 2007 and 2002
    Posts
    1,161

    Re: Update query with multiple Sets and Where conditions

    Glad I was able to help you out.
    Alan

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Search Engine Friendly URLs by vBSEO 3.2.0