AllExperts > Using MS Access 
Search      
Using MS Access
Volunteer
Answers to thousands of questions
 Home · More Using MS Access Questions · Answer Library  · Encyclopedia ·
More Using MS Access Answers
Question Library

Ask a question about Using MS Access
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Scottgem
Expertise
I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience
I've been designing databases for over 15 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

 
   

You are here:  Experts > Computing/Technology > Business Software > Using MS Access > Expiry date

Using MS Access - Expiry date


Expert: Scottgem - 7/10/2009

Question
QUESTION: Hi I am trying to set up a training database, some of the courses dont expire but some do.  i have entered an expiry field on the course form, which i am going to either put years or months. So if a course expired after 3 years in this field i will either put 3 or 36 depending on which ever is easiest.

my question is though how can i get ms access to record the expiration date using the StartDate field and the Expiry date field, on the attendees subform??

ANSWER: As a general rule we do not store calculated values. So there is no need to store this information. But you do need to display it. So what you would do is set the ControlSource of the Expiry control on the subform like this:

=DateAdd("m",Forms!mainformname!Expiry,[StartDate])

I would use months for the expiration period so you don't need to try and determine whether the period is months or years.

Hope this helps,
Scott<>
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA

---------- FOLLOW-UP ----------

QUESTION: I have one last question. I have got the forms working perfectly but now i need a report that takes the expiry date from the attendees subform and put this on a report.  Also I need the report to have a parameter, so if I put the year 2010 in it will show all the attendees who's courses expire that year.

Answer
You do this in a query. In your query add a column like so:

Expiration: DateAdd("m",[Expiry],[StartDate])

I would add a second column:

ExpYr: Year([Expiration])

I would set the criteria for that column to:

[Enter Year]

I would then create a report based on the query.

Hope this helps,
Scott<>
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.