Results 1 to 11 of 11

Thread: Delete Top

  1. #1
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Unanswered: Delete Top

    Can I delete the TOP 70 recordes?

    I can SELECT them, but how can I delete them?
    Thanks

  2. #2
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    If you can select in a form or in a subform press the delete key.
    Saludos
    Norberto

  3. #3
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Originally posted by Norberto
    If you can select in a form or in a subform press the delete key.
    I do that through the Query, so I can select the first 70 records, but I can not press the delete key.

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Originally posted by hammbakka
    I do that through the Query, so I can select the first 70 records, but I can not press the delete key.

    I want to do that per code
    so I wrote
    ff = "SELECT TOP 70 mainTable.* INTO subTable FROM mainTable;"
    doCmd.RunSql(ff)



    No I could copy the first 70 Records in a subTable and I want now to delete these 70 mRecordes form the [mainTable]

  5. #5
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    I thing you can use a Delete Query, use the subTable for delete only thats record in the mainTable.....
    Saludos
    Norberto

  6. #6
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Originally posted by Norberto
    I thing you can use a Delete Query, use the subTable for delete only thats record in the mainTable.....
    In the Delet Query you can not use DELETE TOP 10, like the SELECT TOP 10

  7. #7
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    Then you have only one way....make a code and use ADO....
    Saludos
    Norberto

  8. #8
    Join Date
    Nov 2003
    Location
    NJ, USA
    Posts
    8
    1. copy all the wanted records into a query or temp table
    2. delete all the records in the table
    3. copy all the records from the query or temp table back in to the table

  9. #9
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Originally posted by tbz
    1. copy all the wanted records into a query or temp table
    2. delete all the records in the table
    3. copy all the records from the query or temp table back in to the table
    Thank you for replying,
    my problem is, I want to split a table contains say 1700 records, so I selected the first say 400 records in a temp1 Table, Then I want to delete these 400 from the main table in order to be able to select the next 400 records in a Temp2 Table

    I used the doCmd.RunSql to do that

    ff = "SELECT TOP 400 mainTable.* INTO subTable FROM mainTable;"
    doCmd.RunSql(ff).

    Now I want to delete these 400 records form the main table.

  10. #10
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    select top 400 *
    into temptable1
    from maintable

    select top 400 *
    into temptable2
    from maintable
    where id not in
    (select id from temptable1)

    select top 400 *
    into temptable3
    from maintable
    where id not in
    (select id from temptable1)
    and id not in
    (select id from temptable2)


    neat, eh? no deletes required!


    rudy
    http://r937.com/

  11. #11
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Originally posted by r937
    select top 400 *
    into temptable1
    from maintable

    select top 400 *
    into temptable2
    from maintable
    where id not in
    (select id from temptable1)

    select top 400 *
    into temptable3
    from maintable
    where id not in
    (select id from temptable1)
    and id not in
    (select id from temptable2)


    neat, eh? no deletes required!


    rudy
    http://r937.com/
    It sounds very good, thank you very much for the nice and perfect Idea.

Posting Permissions

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