Solved

Selecting the best record in a subset in a table

Posted on 2014-01-22
3
289 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
3 Comments
 
LVL 34

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 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now