Results 1 to 11 of 11
  1. #1
    rivergum_23 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Nov 2011
    Posts
    14

    Last Entry

    Hi Guys,



    I'm having trouble with one of my queries. (Very simple or so I thought)

    I have 3 columns

    ID (Autonumber) | Part (Text) | Name (Text)

    All I want my query to do is go to the highest "ID" (last entry) and return
    the that row (ID | Part | Name)

    In the query I have the "Total" set to "last" on all columns, however the query returns not always the last entry or highest ID.

    Can anybody suggest why this happens???

    And how to fix it.

    Thanks Heaps,
    River

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    "Last" sometimes gives irregular results. Try "Max" instead.

    BTW, the term Name is a reserved word in Access. Suggest you change the fieldname to something else, as it may cause issues in the future.

    Alan

  3. #3
    rivergum_23 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Nov 2011
    Posts
    14
    Hi Alansidman,
    Thanks for your reply. I have made both changes (Max & Name to Op_Name). It now queries and finds the last ID, however it finds the max in every column rather than the max ID and that row.

    How do I get the query to find the max ID and then display it corresponding "Part" & "OP_Name" what am I missing.

    I probably seems like an easy answer, however I not overly good with query's.

    Thanks in advance.

    River

  4. #4
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    Had a minute so I developed an SQL that will give you the record with only the max ID.
    Code:
    SELECT Table3.ID, Table3.PartNr, Table3.PName
    FROM Table3
    WHERE (((Table3.ID)=(Select Max(ID) from Table3)));
    I mislead you in the earlier answer. You need to have a subquery as shown here. Change the table and field names appropriately and open your query in SQL and paste in the revised statement. Then look at the design grid to see what it look like.
    Alan

  5. #5
    rivergum_23 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Nov 2011
    Posts
    14
    I have attached a image of the screen. I have not used any SQL, perhaps that's the problem.

    Just to recap, I require the query to show max ID and its row of data

    Cheers,
    River

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    This may be what you want:

    http://www.baldyweb.com/LastValue.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by rivergum_23 View Post
    I have attached a image of the screen. I have not used any SQL, perhaps that's the problem.

    Just to recap, I require the query to show max ID and its row of data

    Cheers,
    River
    Your screenshot shows you have MAX in EVERY COLUMN. It should ONLY be in the ID column if you want the last ID. The others should show GROUP.

  8. #8
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    Did you try the instructions I gave you in my last post?

  9. #9
    rivergum_23 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Nov 2011
    Posts
    14
    Hi Alansidman,
    I tried you code, however it gave me parentheses error. I'm guessing that it was something to do with what I was doing.

    boblarson, I tried using the "Group By" in the other columns, however the query would return all entries.

    To make it easy for you guys I've attached the access file so you can see what I'm doing or not doing

    All I want to do is for the report to display the last entry (in this case 66) and it corresponding entries.

    And a big thanks for all of you giving me a hand.

    River.

  10. #10
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    See attached.

    Edit: Just noticed that there was a report also. Change the Record Source from Max of ID in the properties to ID for the report.

    Alan

  11. #11
    rivergum_23 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Nov 2011
    Posts
    14
    Hi Alan,
    Thanks heaps for you help.

    Very much appreciated.

    River

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

Similar Threads

  1. form for New Entry Only
    By bopsgtir in forum Forms
    Replies: 3
    Last Post: 12-30-2010, 09:11 AM
  2. Opening to new entry
    By chazcoral2 in forum Forms
    Replies: 1
    Last Post: 07-02-2010, 11:33 AM
  3. Date entry
    By kellyd in forum Access
    Replies: 3
    Last Post: 09-24-2009, 02:23 PM
  4. Table Entry Sum
    By seraph in forum Access
    Replies: 5
    Last Post: 08-15-2009, 09:49 AM
  5. Entry into subform
    By lynchoftawa in forum Forms
    Replies: 1
    Last Post: 06-17-2009, 09:28 AM

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