A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

default value



 
 
Thread Tools Display Modes
  #1  
Old August 14th, 2009, 04:17 AM posted to microsoft.public.access.gettingstarted
Leroy
external usenet poster
 
Posts: 20
Default default value

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?
  #2  
Old August 14th, 2009, 05:31 AM posted to microsoft.public.access.gettingstarted
LeRoy54
external usenet poster
 
Posts: 2
Default default value


--
LeRoy54


"LeRoy" wrote:

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?

  #3  
Old August 14th, 2009, 06:55 AM posted to microsoft.public.access.gettingstarted
John W. Vinson
external usenet poster
 
Posts: 18,261
Default default value

On Thu, 13 Aug 2009 20:17:02 -0700, LeRoy
wrote:

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!
--

John W. Vinson [MVP]
  #4  
Old August 14th, 2009, 01:15 PM posted to microsoft.public.access.gettingstarted
John Spencer
external usenet poster
 
Posts: 2,364
Default default value

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
'================================================= ===


John W. Vinson wrote:
On Thu, 13 Aug 2009 20:17:02 -0700, LeRoy
wrote:

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!

  #5  
Old August 16th, 2009, 07:07 AM posted to microsoft.public.access.gettingstarted
LeRoy54
external usenet poster
 
Posts: 2
Default default value

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.
--
LeRoy54


"John Spencer" wrote:

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
'================================================= ===


John W. Vinson wrote:
On Thu, 13 Aug 2009 20:17:02 -0700, LeRoy
wrote:

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!


  #6  
Old August 16th, 2009, 07:29 PM posted to microsoft.public.access.gettingstarted
John Spencer
external usenet poster
 
Posts: 2,364
Default default value

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
'================================================= ===


LeRoy54 wrote:
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.

  #7  
Old August 16th, 2009, 11:58 PM posted to microsoft.public.access.gettingstarted
John W. Vinson
external usenet poster
 
Posts: 18,261
Default default value

On Sat, 15 Aug 2009 23:07:01 -0700, LeRoy54
wrote:

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.
--

John W. Vinson [MVP]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:59 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.