Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / May 2005

Tip: Looking for answers? Try searching our database.

Setting up a date query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pearl - 07 May 2005 11:18 GMT
I have a table that has a field called "Type". It is a combo field that has
values:  Revision and Review.  Based on the selection, there is another field
in the table called DATE.  So, there can be a selection called Review with an
associated DATE and a selection Revision with an associated DATE.  What I
would like to do is setup a report based on a query that calculates the NEXT
DUE DATE.  To determine the NEXT DUE DATE I need to take the LATEST date from
either REVISION or REVIEW and then calculate 12 months later for the NEXT DUE
DATE.  Can anyone advise me on how best to do this?  I've never dabbled in
VBS or VBA so I'd like to see if I can get this done with just the tools in
MS Access 2000.  Thanks.
John Vinson - 08 May 2005 03:24 GMT
>I have a table that has a field called "Type".

That's a reserved word and a bad choice of fieldname.

>It is a combo field that has
>values:  Revision and Review.  Based on the selection, there is another field
>in the table called DATE.  

That's another reserved word and also a bad choice of fieldname.
You'll need to ALWAYS enclose both these names in [square brackets] or
Access *will* get confused!

>So, there can be a selection called Review with an
>associated DATE and a selection Revision with an associated DATE.  What I
[quoted text clipped - 4 lines]
>VBS or VBA so I'd like to see if I can get this done with just the tools in
>MS Access 2000.  Thanks.

Neither VBA nor VBS (??) is needed: you can put a calculated
expression in a query. Note that a "combo field" is apparently an
instance of the dreaded and despised "Lookup Field" - the table does
NOT containwhat it appears to contain ("Revision" or "Review"), it
contains a concealed numeric link to the lookup table. I don't know
what that table might be named so I can't include it in a sample
query. Mixing in the lookup table makes my idea of a simple DMax()
function call problematic!

Instead, create a Query joining your main table to the lookup table.
Select the field that contains "Review"/"Revision" and put a criterion
on it of

IN("Review", "Revision")

to select just those two options. Select the [DATE] field and whatever
field you want to group by (I presume that this table contains
information about Projects or something similar and you want the
latest date for each project?)

Change the query to a Totals query by clicking the Greek Sigma icon
(looks like a sideways M). Group By this field; use WHERE as the
totals operator on the Type field; Group By the Project ID (whatever
it is); and select Max on the Date field. This will give the latest
review or revision date (whichever is later) for each project. Include
this Totals query in your report's recordsource query, joining by
ProjectID.

You can then use a textbox on your report with

=DateAdd("yyyy", 1, [MaxOfDate])

to calculate the next due date.

                 John W. Vinson[MVP]    
Pearl - 09 May 2005 12:56 GMT
many thanks for the advice.  I'll change the field names so that they don't
confuse Access.

> I have a table that has a field called "Type". It is a combo field that has
> values:  Revision and Review.  Based on the selection, there is another field
[quoted text clipped - 6 lines]
> VBS or VBA so I'd like to see if I can get this done with just the tools in
> MS Access 2000.  Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.