Set date control when form opens

Sandra Smith
Sandra Smith used Ask the Experts™
on
I have an Access 2003 form that when it opens, I want the text control, txtDate, to simply be the date of the End of the MOnth for the prior month.  However, whenever I try to pass in today date via the Date function, it keeps error indicating it is a null value.  Can a text field be initialized to a date usign the form open event?  

Sandra
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Database Architect / Application Developer
Top Expert 2007
Commented:
Try this:

Me.YourDateTextBox = DateSerial(Year(Date()),Month(date()),0)

mx
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:
For example ...

DateSerial(Year(Date()),Month(Date()),0)
Returns 04-30-2012
Sandra SmithRetired

Author

Commented:
Thank you.  I simply never think of the DateSerial and it always seems to solve my issues.

Sandra
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:
Pretty handy ...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial