Results 1 to 4 of 4
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post

    Update query (2003)

    I'm trying to run an update query where I update a field with data from an identical field in another identical table. For practice, I've built a little test database with two identical tables: tblWidgets and tblWidgets_1. The latter table is a copy of the former. The tables have nine records and three fields: WidgetID, WidgetName [text field], and WidgetStatus [Yes/No field]. WidgetStatus is the field I want to update. In the first table (tblWidgets), the first five records are Yes. In the second table, all nine records are Yes.

    I've built an Update query, but when I run it, nothing changes. Could someone take a look at my efforts and tell me what I've overlooked. Thanks!

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update query (2003)

    You have add two times the table tblWidgets with result in the query : table tblWidgets and tblWidgets_1.
    If you delete the table tblWidgets_1 and replace it by tblWidgets1 (without underscore) and adjust the update to line to [tblWidgets1].[WidgetStatus] (without underscore) it will work.
    Francois

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post

    Re: Update query (2003)

    Thank you! Yes, it works with that change. I'd seen the extra underscore, but I didn't know how it got there. That made all the difference.

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update query (2003)

    When you add two times the same table in a query, Access add _1 to the name of the table. But it is the same table. In your case, you try to update the field WidgetStatus from table tblWidgets with the field WidgetStatus from table ... tblWidgets instead from table tblWidgets1.

    This is the sql from your first query:
    UPDATE tblWidgets INNER JOIN tblWidgets AS tblWidgets_1 ON tblWidgets.WidgetID = tblWidgets_1.WidgetID SET tblWidgets.WidgetStatus = tblWidgets_1.WidgetStatus;

    This is the sql from the corrected query :
    UPDATE tblWidgets INNER JOIN tblWidgets1 ON tblWidgets.WidgetID = tblWidgets1.WidgetID SET tblWidgets.WidgetStatus = [tblWidgets1].[WidgetStatus];
    Francois

Posting Permissions

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