Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Selecting the best record in a subset in a table

Posted on 2014-01-22
3
Medium Priority
?
320 Views
Last Modified: 2014-01-22
Access 2010

I have a table called "Belts"

Fields:
Item-Text
Mfrnum-Text
Mfrname - Text
Score-Text
REDBOOKPAGE-Text
Tag-Text


In Table I have repeating values in the Mfrnum field when a filter is in place for the Mfrnum field for a particular value like as shown.
In this case i'm filtering "1000H075" in the table.

Example of a filterWhat I need: based on the "Score" field. What ever score record  has the highest value in the "Score" field. Then a "Y" gets placed  in the "Tag" Field for only the highest value score.


In the case where the highest value is the same pick the top records in the filter.

I'm indexing by  "Mfrnum" asc... and then  "Score"  descending in the filter.


Thanks
fordraiders
0
Comment
Question by:fordraiders
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 39

Expert Comment

by:PatHartman
ID: 39800859
If you are talking about the Tag property of a control on the form, this won't work.  Access maintains only a single instance of values for continuous/datasheet forms so setting the Tag property of a control sets it for all instances of the control.

Tell us more about what you need this for.  You should be able to find the record by sorting the records descending by the score and then adding  Top 1 to the query.
0
 
LVL 48

Accepted Solution

by:
Dale Fye earned 2000 total points
ID: 39800904
Tag is a reserved word, so you might want to think of a different field name so you don't have to wrap it in [ ] every time you use it.

Do you only want to do this when you filter the data, or do you want to update it for all MFRNUM in your table?

You might try:

UPDATE Belts as B
SET [Tag] = "Y"
WHERE [Score] = DMAX("Score", "Belts", "MFRNum = '" & B.MFRNUM & "'")

This would update [Tag] to "Y" for the record with the maximum [Score] within each MFRNUM.
FROM
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 39801843
Thanks very much
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question