default value

L

LeRoy

Help! I currently know how to create the following: =CDate(Month(Date()) &
"/10/" & Year(Date())) as a default value in "Access 2003". What value or
expression can I use to create a "month" instead of a date value?
 
J

John W. Vinson

Help! I currently know how to create the following: =CDate(Month(Date()) &
"/10/" & Year(Date())) as a default value in "Access 2003". What value or
expression can I use to create a "month" instead of a date value?

What do you want in this "month"?

An Access Date/Time value cannot be just a month - it's actually stored as a
number, a count of days since midnight, December 30, 1899. As such any date
value refers to a specific moment of time.

It's not clear what you're trying to create!
 
J

John Spencer

This function may be a little better as it creates a date which is the
tenth of the current month.

DateSerial(Year(date()),Month(Date()),10)

What do you mean by 'create a "Month"'? Do you want a month name, a
month number, a date range from the 1st of the month to the last day of
the month, or something else?

You can use the Format function to get the month name
Format(somedate,"mmmm") or Format(SomeDate,"mmm")

You can use the MonthName function
MonthName(8) returns August

You can use DatePart to get the month number
DatePart("m",SomeDate)

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
L

LeRoy54

I use it as part of a default value in a field name (in a access table) when
to set as default date to keep from retyping a date when I open and use it on
a form.

Also, how do I make it go backward one month, If I don't want to use it as a
current month.
 
J

John Spencer

This expression
DateSerial(Year(Date()), Month(Date())-1,10)
will return the tenth day of the previous month.


'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
J

John W. Vinson

I use it as part of a default value in a field name (in a access table) when
to set as default date to keep from retyping a date when I open and use it on
a form.

Also, how do I make it go backward one month, If I don't want to use it as a
current month.

You can't use a function in a table default value... but you can use

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

as the default value of a textbox on a Form to get the tenth of last month
into the textbox's bound column.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top