Solved

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

Posted on 2013-06-26
3
705 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

760 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

19 Experts available now in Live!

Get 1:1 Help Now