Results 1 to 9 of 9
  1. #1
    Juicejam is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Feb 2011
    Posts
    44

    Have a query go to a specific sequential record

    I need a form (with a nested sub-form) to display a numbered record of a query, e.g. I need the first to eight records of a dynamic query displayed. I currently use the gotorecord action of the docmd argument but am having trouble when the query doesn't have any records.

    I guess I could do some sort of error trapping in the code but I am wondering if there is a way to actually get the query (in SQL) to go to the specific record when it is run. Can queries do this?

    Thanks very much...

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Do the records have some sort of ID number?
    There is no specific order to records in a table. You can place an order on records if you use a query and include an ORDER BY clause.

  3. #3
    Juicejam is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Feb 2011
    Posts
    44
    No, not sure sorting by id number would work. The query sorts by date/time order and I need to show the latest/newest 8 records in the query.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Research the Select TOP query. Order by the Date/time field descending.

  5. #5
    Juicejam is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Feb 2011
    Posts
    44
    ok thanks but i am looking to isolate one record at a time. Guess I will have to stick to the gotorecord command.

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Use the select TOP x ... Order By ... as a recordset and process the records by means of a loop.

  7. #7
    Juicejam is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Feb 2011
    Posts
    44
    Hi Orange, thanks. Can you give me an exampe of processing the recordset by means of a loop? is this via code?

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  9. #9
    Juicejam is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Feb 2011
    Posts
    44
    Okay thanks, it looks like all gibberish to a novice like me but i will give it a go...
    I dont have a recordset in code, I was working with a built query in access then moving through that query using code.

    I may have to come back to you for more help, if you can...

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

Similar Threads

  1. Open form to a specific record from a query
    By chris.williams in forum Forms
    Replies: 11
    Last Post: 10-06-2011, 04:15 PM
  2. Replies: 11
    Last Post: 07-14-2011, 03:03 PM
  3. How to add sequential numbers to query resultset
    By h_latha2k in forum Queries
    Replies: 3
    Last Post: 04-29-2011, 08:53 PM
  4. Adding record with next sequential number
    By stanley721 in forum Forms
    Replies: 3
    Last Post: 02-28-2011, 01:26 PM
  5. Adding Sequential Values to Make-Table Query
    By obrien.robj in forum Queries
    Replies: 2
    Last Post: 08-25-2010, 12:55 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