Access 2007-2019
Access 2000-2003
Access Seminars
TechHelp Support
Tips & Tricks
Access Forum
Course Index
Topic Glossary
Insider Circle
 
Home   News   Tips   Glossary   Templates   Forums   Help   Logon   Order   Contact Us  
 

News      User Comments     History     Notify Me

10/7/2007 4:24:24 PM
Access Q&A: Dates, DCount
By Richard Rost   Richard Rost on Facebook Richard Rost on Twitter Richard Rost on Google Plus Richard Rost on LinkedIn Email Richard Rost

 
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

Permanent Link
Keywords: access tips dates dcount dlookup
Post Reply

Notifications Comment from 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
Show Just This Thread        Post Reply
Calculating Dates based on Day of the Month Comment from 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.

In this case the 30 mo date would be 12/1/12 and the 6 mo would be 3/1/12.
Show Just This Thread        Post Reply

Add Your Comments or Subscribe
 
If you just want to subscribe to get email updates when the News is updated, then enter your name and email address and check the Notify Me box below. If you would optionally like to add your comments below to be posted, they are welcome.
 
  Your Name:  Required
  Your Email:  NOT Public
  Subject:
  Comments:

 

Sorry about this step. It's just to keep the spam bots away:
  Verify: What is 7+5:
  
  Notify me when the News is updated.
  Remember Me for my next comments
  
 
 
Please do not use this form for Customer Service inquiries! If you have questions about your account, shipping info, courses you've ordered, need passwords, etc. please use the Customer Service Center instead.

I value your comments. They will be displayed on this page (above). Your name will be displayed, but your email address will not be.
As always, I promise to never give away your personal information to anyone else, ever.

NOTE: If you don't leave your name and email address, DON'T expect a reply. I can't promise a personal reply to everyone who posts here. I TRY my best, but I cannot guarantee it. If you don't leave your real name and email address, I won't even bother. I usually just hit DELETE. -Richard

 

 

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

8/15/2019Last Chance for Access CDs
8/1/2019Customer List Form Template
8/1/2019New Template Access Customer Database
7/30/2019Microsoft Access Developer 13
6/20/2019TIP: Validation Rules in Access
11/20/2018Microsoft Access Developer 12
8/25/2018NEW: Access Dev 9, 10, 11
8/25/2018Microsoft Access Developer 11
8/25/2018Microsoft Access Developer 10
8/25/2018Microsoft Access Developer 9
 

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 Our Site
Waiting List
Production Schedule
Collapse Menus
Help
 
Live Chat
Customer Support
WalkThru Tutorials
Troubleshooting
FAQs
TechHelp
Consulting Services
About Us
 
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 Us
Mailing Address
Phone Number
Fax Number
Course Survey
Facebook    Twitter

Google Plus    LinkedIn

Blog RSS Feed    YouTube Channel
Richard Rost Microsoft MVP