Access 2007-2019
Access 2000-2003
Access Seminars
TechHelp Support
Tips & Tricks
Access Forum
Course Index
Topic Glossary
Insider Circle
 
Home   News   Courses   Tips   Templates   Forums   Help   Order   Contact   Logon  
 
NEW: Excel Expert 11 - Learn XLOOKUP    dismiss
 
Access Q&A: Dates, DCount
By Richard Rost   Richard Rost on Facebook Richard Rost on Twitter Richard Rost on LinkedIn Email Richard Rost   10/7/2007 4:24:24 PM

Here are some Access questions I've answered recently:

hello richard, i have question regarding how to set up a validation for the date field, where the date can be just within the current month. can u pl help? thanks, sapna

Make your ValidationRule property for this field:

Month([MyDateField])=Month(Date())

Of course, this will only work while the data is being entered.




Hi Richard. I am trying to query some data for a period from today's date back to 30 June. I will always want to query from today's date (whatever it may be). I tried "Between 30/06/2007 And Now()" as a criteria, but it doesn't appear to do the trick. Can you suggest a solution?

I tried it, and it worked fine for me, but make sure you have the "#" symbols around your dates. Access cannot figure out what you mean otherwise - it will try to treat it as a division problem. I'm in the US, so my date format would me the criteria:

Between #6/30/2007# and Date()+1

The reason I use Date()+1 is because I want to INCLUDE today's data. Remember, dates are treated as of midnight, so by making it tomorrow at midnight, I get all of today's values. Sure, you can use Now() if you want it accurate to the second.

Read more of my Access tips at www.599cd.com/tips





Hello!
I have an application with two tables (simplified version)

table person
column id
column name

table shift
column id
column person_id

There is a one-to-many relationship between the shift table and the person table. So many people can work the same shift. However, i need to limit the number of people on a shift to some number, say 5. How can I do this? I assume I'd need to use some code in the "Before Insert" on the form where I'm adding the records, but I have no clue how to do it.
Thanks for taking the time to read this.



I would use the DCOUNT function to see how many people are already in that shift.

NumWorkers = DCOUNT("*","ShiftTableName","ShiftID=" & ShiftID)

In english, this says, "create a variable called NumWorkers. Set it equal to the count of ALL records (*) in the ShiftTableName table, where the ShiftID equals whatever the current ShiftID on my form is."

I would make a form showing the workers in each shift, and put an unbound combo box with a list of your workers in the FOOTER of the form along with a button to add another worker. Have this code run in the button BEFORE the worker is inserted.

I cover this technique in my advanced Access classes starting with Access 301 (www.599cd.com?goac301). I teach the DLOOKUP function in Access 302 which is almost exactly like DCOUNT.

Read more of my Access tips at www.599cd.com/tips

Notifications Link 
Alexander H - 11/17/2013
Hi Jacqueline,

Have you seen the Birthday Tip from Rich?

You could combine this with a DateAdd function. Read More...
Loading...
Add Your Comments
Notifications Link 
Jacqueline - 11/11/2013
Hi, I am wanting to create an future alert for 9months from a Date of Birth variable. Could you please explain how to do this? I am very new to ACCESS.
thanks
Loading...
Add Your Comments
Calculating Dates based on Day of the Month Link 
Bernadette Torres - 9/18/2012
Hello,

I am wanting to calculate dates as follows:

Original Date:  9/5/12
3 Mo
6 Mo

If the original date is a day between the 16th and 31st of the month I want the 3 mo field to populate to the 1st of the month.  If the original date is between the 1st & 15th I want the date to calculate to the 15th of the month. Read More...
Loading...
Add Your Comments

 

Post Your Comments
 
Only students may post right now. Click here for more information on how you can set up an account. If you are a student, please LOG ON first.
 
Subscribe
 

You may want to read these articles from the 599CD News:

5/30/2020Two New Access Handbooks
5/30/2020Access Tip Sleep Timer
5/18/2020Access Record Source Property
5/3/2020Access Replace Function
5/1/2020Microsoft Access Tutorials
4/24/2020Access Discontinued?
4/21/2020Date Time Clock Picker Template
4/20/2020Access Backup Record Before Edited
4/17/2020ZIP Code Lookup Template
4/16/2020Access Round Nearest 10
 

Learn
 
Accessindex
Excelindex
Wordindex
Windowsindex
PowerPointindex
Photoshopindex
Visual Basicindex
ASPindex
Seminars
More...
Customers
 
Account Login
Online Theater
Downloads
Lost Password
Free Upgrades
Insider Circle
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Articles
Search The Site
Waiting List
Production Schedule
Collapse Menus
Help
 
Live Chat
Customer Support
WalkThru Tutorials
Troubleshooting
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Order
 
Video Tutorials
Handbooks
MYOLP Memberships
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Gift CDs
Contact
 
Live Chat
General Info
Support Policy
Contact Form
Email Richard
Mailing Address
Phone Number
Fax Number
Course Survey
Facebook    Twitter

YouTube Channel    LinkedIn

Blog RSS Feed   
Keywords: access tips dates dcount dlookup  PermaLink