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
Solved

Access 2010 - How to set a constant to a query result

Posted on 2013-06-26
3
718 Views
Last Modified: 2013-06-26
Hi Experts,

I have a database with a table (t_datadate).  I have a query q_DataDate_MAX which uses Max to find the most recent date.  I often have to join this query to a date field in other queries to filter for one date, however, I was hoping I could just use something that acts like a global constant under Criteria in the query grid instead.  Since the max date often changes, I know I can't define a constant as a specific date (I've found VBA examples on this), but wondering how I could have the constant equal to the result of the Max date query?  Maybe I'm using the wrong concept to try and accomplish this, so please forgive my ignorance : )
0
Comment
Question by:grmcra
  • 2
3 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39278693
You can use DMAx:

Constant = dmax("yourdatefield" , "yourtable")
0
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 500 total points
ID: 39278722
An alternative is to use DLookup to pull the MaxDate from your existing query:

x = DLookup("YourFieldName", "q_DataDate_MAX")


See Jim Dettman's article about DLookup and the Domain functions for a thorough explanation of this topic:
http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_12-Dlookup-and-the-Domain-Functions.html
0
 

Author Closing Comment

by:grmcra
ID: 39278860
Works great and thanks for the resource link!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

766 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