Results 1 to 7 of 7
  1. #1
    stanley721 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    32

    Angry Returning only the last number in a field

    OK, I've read many solutions and used several methods for similar situations, but I keep getting odd results, of which are not what I want. I will try to explain in detail so that I can get the most customized results.
    I have a training database with a table that has the following fields:
    "Job Area" "Duty Area Number" "Task Number" "Task Name"



    as well as a few other fields, but they all just contain extraneous info. Now I run a query that asks what "Duty Area" I want. I can input the Duty Area # and it returns all the Tasks from that Duty Area. Works great, all's good. Now I would like for the results to only return the last Task Number from that Duty Area, so after running the query, I should have only one record returned to me. I have tried using the DMAX function as well as several other ways using Macros and others. Maybe I'm not putting the code in right or in the right place. This seems soooo simple but it is kicking my rear in a bad way! Can someone please help?! Let me know if you need any more info to clear things up.

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    It sounds like you need a totals query that uses the Max() function not the DMax() function

    Assuming that you want to group by duty area number within job area, the query may look something like this:

    SELECT [Job Area],[Duty Area Number], Max([Task Number]) AS MaxOfTaskNumber
    FROM yourtable
    GROUP BY [Job Area],[Duty Area Number]

  3. #3
    stanley721 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    32
    I've tried that and it doesn't work. As a matter of fact, it returns all of the Task Numbers in a weird random order. I'll attach a picture of the screen capture.

  4. #4
    stanley721 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    32
    Here is a view of the query.

  5. #5
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You cannot include any other fields in the totals query, so it must be as follows

    SELECT [Job Area],[Duty Area Number], Max([Task Number]) AS MaxOfTaskNumber
    FROM yourtable
    GROUP BY [Job Area],[Duty Area Number]

    You will need to create another query that joins the totals query above with the table that has the other fields you want to display. You will have to make a join between the 3 fields of totals query and the corresponding fields in the other table.

  6. #6
    stanley721 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    32

    Talking

    Sweet! That did it. You don't know how happy that makes me. I have been working on this for a couple of days and by getting this done, it also helps fix a few others things I was trying to accomplish.
    Thanks!!!!

  7. #7
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You're welcome. Glad that worked out for you.

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

Similar Threads

  1. Replies: 12
    Last Post: 10-15-2010, 10:03 AM
  2. Field displays number instead of value
    By rdueck in forum Reports
    Replies: 6
    Last Post: 02-25-2010, 08:19 PM
  3. about number field in table
    By spradhan in forum Access
    Replies: 1
    Last Post: 02-19-2010, 12:44 PM
  4. How to Increment A Number Field
    By Advanced in forum Programming
    Replies: 3
    Last Post: 01-27-2010, 02:36 PM
  5. Report the number of occurrences in a field
    By ecpike in forum Reports
    Replies: 1
    Last Post: 05-05-2009, 01:57 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