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 / Forms Programming / June 2007

Tip: Looking for answers? Try searching our database.

date default issue

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JohnE - 04 Jun 2007 22:09 GMT
I have a form that has 2 fields on it; one for begin date and the other for
end date.  The users want both of these fields to default to the first day
and last day of the previous month.  (ex:  we are in June so the defaults
would be 5/1/2007 and 5/31/2007).  I am at a lost on doing this and ask for
help from the news group.  
Thanks for any help given.
... John
Ofer Cohen - 04 Jun 2007 22:23 GMT
You can write it either in the form text box or in the table fields, in the
default value

In the Start Date
DateSerial(Year(DateSerial(Year(Date()), Month(Date()),
0)),Month(DateSerial(Year(Date()), Month(Date()), 0)),1)

In the End Date
DateSerial(Year(Date()),Month(Date()),0)
Signature

Good Luck
BS"D

> I have a form that has 2 fields on it; one for begin date and the other for
> end date.  The users want both of these fields to default to the first day
[quoted text clipped - 3 lines]
> Thanks for any help given.
> ... John
JohnE - 04 Jun 2007 22:34 GMT
Perfect!
Thanks.

> You can write it either in the form text box or in the table fields, in the
> default value
[quoted text clipped - 13 lines]
> > Thanks for any help given.
> > ... John
Rick Brandt - 04 Jun 2007 22:44 GMT
> You can write it either in the form text box or in the table fields,
> in the default value
>
> In the Start Date
> DateSerial(Year(DateSerial(Year(Date()), Month(Date()),
> 0)),Month(DateSerial(Year(Date()), Month(Date()), 0)),1)

Why all of that when...

DateSerial(Year(Date()), Month(Date())-1,1)

...gives the same result?

Signature

Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com

Ofer Cohen - 04 Jun 2007 22:58 GMT
You right Rick

For some reasone I thought that I'll have a problem with January, you method
is correct

Thank you

Signature

Good Luck
BS"D

> > You can write it either in the form text box or in the table fields,
> > in the default value
[quoted text clipped - 8 lines]
>
> ....gives the same result?
Rick Brandt - 04 Jun 2007 22:23 GMT
> I have a form that has 2 fields on it; one for begin date and the
> other for end date.  The users want both of these fields to default
[quoted text clipped - 3 lines]
> Thanks for any help given.
> ... John

Default Values of...

=DateSerial(Year(Date()), Month(Date())-1, 1)
=DateSerial(Year(Date()), Month(Date()), 0)

Signature

Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com

 
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.