Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 2nd, 2012, 12:24 PM
Authorized User
Points: 308, Level: 6
Points: 308, Level: 6 Points: 308, Level: 6 Points: 308, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2009
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default Maximum as a criterion in an Access Query

I need to query a table that contains results of surveys for various pieces of property. One of the fields will be number, beginning with 1, that indicated which survey this set of data represents. I will definitely at times want the data from the first survey and that is an easy query.

But what about when I was the last (highest number) query on a property? That is, for the survey number field, rather than putting in a number (because each property has a different nunber of surveys and I don't readily know how many surveys a given piece of property has had) I want to use the equivalent of MAX in Excel. That is, my criteria for that field is to find the record where that field has the largest value.

If I am not clear, I may have 7 entries for various surveys done over time for Property A. Then again, I may have only two surveys or as many as dozens. I know I could easily run a query to show me how many there are so I would no the highest number used for Property A, but that is a pain to do.

So the question is, can I just put Max or Maximum into the query criterion box for the SurveyNumber field and Property A in that field and get the survey results I am looking for, that is the results for the last survey entered?
Reply With Quote
  #2 (permalink)  
Old March 2nd, 2012, 02:08 PM
Authorized User
Points: 308, Level: 6
Points: 308, Level: 6 Points: 308, Level: 6 Points: 308, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2009
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

First, I should admit that I am not a SQL guy. I sort of understand it, but when I cannot use the Access Query interface, I need to go to books for how to adjust the SQL.

I believe I have discovered an easier way to do this. If I first to a sub query, use the property and survey fields (specifying the property and returning only the survey number in the result), I believe that all I need to do is set the survey number field in descending order and set the properties of the query to return the top one result. And then use this query as part of the basis for my later query to get the results of the needed survey for the specified property.

Anyone see any difficulties in that approach? If not, it is a fairly simple system to use.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Maximum as a criterion in an Access Query rmccafferty Excel VBA 1 March 2nd, 2012 12:26 PM
where clause/criterion sauloftarsus SQL Server 2005 0 November 23rd, 2011 04:15 AM
Update query doesnt run when Select query does (In MS Access) rmccafferty SQL Language 3 February 11th, 2010 04:54 AM
Row Maximum bmains SQL Server 2000 2 October 7th, 2004 08:39 PM
Finding the maximum and using it outside the IF jrwarwick XSLT 2 October 17th, 2003 03:59 AM



All times are GMT -4. The time now is 09:14 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.