Results 1 to 2 of 2
  1. #1
    WSlepecki is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    1

    Using the TOP clause

    Hello,

    I am trying to write a query that will select the first say 1000 records from one table into another table. I was successful using the TOP clause when I wanted to hard code the number of records returned. How do I modify the SQL to allow the user to enter the number of records they want instead of having a fixed number? Help!

    The code that I currently have is:
    SELECT [UNUSED IBM NBRS].ID, [UNUSED IBM NBRS].IBM INTO [IBMs Selected]


    FROM [UNUSED IBM NBRS]
    WHERE ((([UNUSED IBM NBRS].ID) In (SELECT TOP 1000 ID
    FROM [UNUSED IBM NBRS])));

  2. #2
    Rixxe is offline Blessed Bear
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Location
    London (Essex ... yep!)
    Posts
    184
    You can just change the '1000' to the name of your textbox in which the user will enter a number. If you are using a form or something similar
    SELECT [UNUSED IBM NBRS].ID, [UNUSED IBM NBRS].IBM INTO [IBMs Selected]
    FROM [UNUSED IBM NBRS]
    WHERE ((([UNUSED IBM NBRS].ID) In (SELECT TOP &TextBoxUser& ID
    FROM [UNUSED IBM NBRS])));

    Now obviously that isnt the right syntax, but google should help with that. Guess is that you will need some VBA, but then i'm really not sure, you might just be able to add the textbox name and run it

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

Similar Threads

  1. Where clause
    By Amerigo in forum Queries
    Replies: 2
    Last Post: 03-30-2011, 07:34 AM
  2. WHERE clause - Longshot
    By shexe in forum Queries
    Replies: 1
    Last Post: 09-22-2010, 02:39 PM
  3. Where clause syntax
    By stupesek in forum Reports
    Replies: 7
    Last Post: 09-03-2010, 02:26 PM
  4. IIF clause
    By Peljo in forum Queries
    Replies: 2
    Last Post: 02-05-2008, 11:22 AM
  5. Help on WHERE clause
    By QBCM in forum Programming
    Replies: 1
    Last Post: 12-19-2005, 08:43 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