473,386 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Default Date

I'd like the default date in a text box to be 31(dd) + 12(mm) +
2006(current year-1).

The YEAR part of the date should sense that the current year is 2007
and so deduct 1 & set the year as 2006 as indicated above.

So basically the day will always be 31.
The month will always be 12.
The year should be (current year - 1).

How can i accomplish this ?

Rgds,
Prakash.

Aug 1 '07 #1
6 3582
ARC
Try putting this in the "Default Value" property of the text box:
CVDate("31/12/" & Year(Now())-1)


<pr*************@gmail.comwrote in message
news:11*********************@r34g2000hsd.googlegro ups.com...
I'd like the default date in a text box to be 31(dd) + 12(mm) +
2006(current year-1).

The YEAR part of the date should sense that the current year is 2007
and so deduct 1 & set the year as 2006 as indicated above.

So basically the day will always be 31.
The month will always be 12.
The year should be (current year - 1).

How can i accomplish this ?

Rgds,
Prakash.

Aug 1 '07 #2
Thx! Worked like a charm.

I tried searching the Access & VBA Help for the syntax & further details
on CVDate to no avail.

However I did find a little info on the CDate function though not
enough.

Could you point me to any site that has more info on these with some
examples and if possible explain what is the difference between these 2
functions ?

Best Rgds,
Prakash.
*** Sent via Developersdex http://www.developersdex.com ***
Aug 1 '07 #3
ARC
You're welcome. I've never used CDate, and my only source was the access 97
help file, and looking through all the date functions.

I did play with the syntax a bit, and it took a number of tries to get it, I
tried Year(Now() -1), but that errored out.. So you have to take off the 1
after the Year() function, not within it. Definetely trial and error.. After
the inner parens, Access will just see: CVDate("31/12/2006")

"Prakash Wadhwani" <si****@omantel.net.omwrote in message
news:46*********************@news.qwest.net...
Thx! Worked like a charm.

I tried searching the Access & VBA Help for the syntax & further details
on CVDate to no avail.

However I did find a little info on the CDate function though not
enough.

Could you point me to any site that has more info on these with some
examples and if possible explain what is the difference between these 2
functions ?

Best Rgds,
Prakash.
*** Sent via Developersdex http://www.developersdex.com ***

Aug 1 '07 #4

"ARC" <an**@andyc.comschreef in bericht news:jH*******************@newssvr12.news.prodigy. net...
You're welcome. I've never used CDate, and my only source was the access 97
help file, and looking through all the date functions.

I did play with the syntax a bit, and it took a number of tries to get it, I
tried Year(Now() -1), but that errored out.. So you have to take off the 1
after the Year() function, not within it. Definetely trial and error.. After
the inner parens, Access will just see: CVDate("31/12/2006")
Year(Now() -1) or Year (Now -1) will give you 2007, so it did not result in the right output.
Is this what you mean with 'errored out' ??

Also: Now() gives you the date AND the time.
Better use Date() if you only want to use the date.

Another option for OP's question is the DateSerial() function.
DateSerial(Year(Date) -1, 12, 31)

Arno R

Aug 1 '07 #5
ARC
No, what I meant was, if I put the -1 within the Year() parenthesis, I got a
#Error in the text box field (when used in the default value field). When I
moved the -1 out of the Year function, it worked.

You're correct of course, much better to use Date() than Now(). Date Serial
seems like a easier function to deal with.

"Arno R" <ar****************@planet.nlwrote in message
news:46***********************@text.nova.planet.nl ...

"ARC" <an**@andyc.comschreef in bericht
news:jH*******************@newssvr12.news.prodigy. net...
You're welcome. I've never used CDate, and my only source was the access
97
help file, and looking through all the date functions.

I did play with the syntax a bit, and it took a number of tries to get it,
I
tried Year(Now() -1), but that errored out.. So you have to take off the 1
after the Year() function, not within it. Definetely trial and error..
After
the inner parens, Access will just see: CVDate("31/12/2006")
Year(Now() -1) or Year (Now -1) will give you 2007, so it did not result in
the right output.
Is this what you mean with 'errored out' ??

Also: Now() gives you the date AND the time.
Better use Date() if you only want to use the date.

Another option for OP's question is the DateSerial() function.
DateSerial(Year(Date) -1, 12, 31)

Arno R
Aug 1 '07 #6
Thx Arno !

The Date() function does seem more logical and yes ... DateSerial does
seem a better way of going about it.
LYLE ... thx for the tip on how to dig into the Access help. I tried it
& it seems to work a treat. I'm using Access 2003.

Rgds,
Prakash.
*** Sent via Developersdex http://www.developersdex.com ***
Aug 1 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Anna | last post by:
I am an extreme newbie to Access and need help setting a default date on a form. The situation is: I have a field called date_received which is set to default to today's date. I have another...
2
by: Rani | last post by:
guys I've created 3 combo boxes for a month date and a year how do I set the value to be the default date ? is there a more suphisticated way to do so ? herein is the code i am using <select...
1
by: DawnAnne1974 | last post by:
I need to set a default date on a form that when it comes to a Monday, the form from and to dates will default to the Friday to Sunday of the previous week. For all other day, the form should...
0
by: j.t.w | last post by:
Hi, I'm trying to set a default date (today's date) to a bound textbox in an InsertItemTemplate of a FormView control. Currently, the RegDateTextBox value does get inserted when I insert the...
9
by: Rizwan Karedoa | last post by:
Hi experts, I am developing an application, I am using vb 2005 and access. I have many date fields, When I am saving through Query for default date I save 1/1/1500 so when i find that date agian I...
3
by: dpmcdoug | last post by:
I am a relative novice with Access and I am developing an input form that I need a default date to populate, regardless of the input date e.g. If I input data on Tuesday, Sept 27, I want the default...
21
JamesDC
by: JamesDC | last post by:
Hey all, How do I set the default date of my MSCAL.Calendar.7 calendar to today's date? I have it on one of my forms so that an employee can click on a given date and bring up the records form...
0
by: HockeyFan | last post by:
Does anyone know how to have a default date for the CalendarExtender? I'd prefer that the textbox it is associated with, remain blank until the user actually clicks on it, but I also don't want...
1
by: Usman ahmed | last post by:
how do i set a default date of one month from now, this is for the return date field
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.