Results 1 to 7 of 7
  1. #1
    tonyhansson is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Aug 2020
    Location
    Copenhagen, Denmark
    Posts
    34

    Update top 50

    Hi



    I am trying to make a query to update top 50 rows, but can't make it work.

    I have an update query working OK, it compares to tables Flightlist and Flight (Unik is the ID), and update the difference.

    Code:
    UPDATE (SELECT TOP 50 FROM FlightList Where FlightList.Unik = Flight.Unik Order by FlightList.Unik) 
    
    AS Flight LEFT JOIN FlightList ON Flight.Unik = FlightList.Unik SET FlightList.Unik = [Flight].[Unik], FlightList.[D-Time] = [Flight].[D-Time], FlightList.[A/C Type] = [Flight].[A/C Type],
    
    
    What am I doing wrong?


  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    What does can’t make it work mean? You get an error? Wrong result? Something else? If an error, what is the error message? If wrong result? How is it wrong?

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Answers to all of Ajax's questions would be very helpful.
    In the meantime, does this work?

    Code:
    UPDATE FlightList LEFT JOIN FlightList ON Flight.Unik = FlightList.Unik
    SET FlightList.Unik = [Flight].[Unik], FlightList.[D-Time] = [Flight].[D-Time], FlightList.[A/C Type] = [Flight].[A/C Type]
    WHERE FlightList.Unik IN (SELECT TOP 50 FROM FlightList ORDER BY FlightList.Unik)
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  4. #4
    tonyhansson is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Aug 2020
    Location
    Copenhagen, Denmark
    Posts
    34
    Hi

    Sorry my late answer. Thank you for your answer.

    I get a syntax error in Query expression (SELECT TOP 50 FROM FlightList ORDER BY FlightList.Unik) if I use suggestion from isladogs.


    If I use my own solution I get: The SELCT statement includes a reserved word or an argument name this is misspelled or missing, or the punctuation is incorrect.


    Regards


    Tony


  5. #5
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    As Colin is away I'll endeavour to fix this, try adding Unik to the sub select clause;

    (SELECT TOP 50 Unik FROM FlightList ORDER BY FlightList.Unik)
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  6. #6
    tonyhansson is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Aug 2020
    Location
    Copenhagen, Denmark
    Posts
    34
    Hi working

    thank you to all of you

  7. #7
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Oops. Thanks @Minty
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Replies: 2
    Last Post: 06-21-2018, 03:16 AM
  2. Replies: 6
    Last Post: 11-05-2014, 05:27 PM
  3. Replies: 7
    Last Post: 08-26-2013, 06:05 AM
  4. Replies: 2
    Last Post: 08-30-2012, 07:59 AM
  5. Replies: 1
    Last Post: 01-22-2011, 12:23 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