PC Review


Reply
Thread Tools Rate Thread

How to display only date as year (yyyy) in txtbox?

 
 
sebastico
Guest
Posts: n/a
 
      17th May 2010
Hello
Access 2003.

I have this code which works well. However, I would like to display only
year (yyyy) in textStart rather than day/month/year. Could you help me how
to do it?

txtStart Default Value : Date()

Private Sub bAddYear_Click()
Select Case Me.fraOptions.Value
Case Is = 1
Me.txtStart.Value = DateAdd("yyyy", 1, [txtStart])
Case Is = 2
Me.txtStart.Value = DateAdd("yyyy", 5, [txtStart])
Case Is = 3
Me.txtStart.Value = DateAdd("yyyy", 10, [txtStart])
End Select

Thanks in advance
 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      18th May 2010
"sebastico" <(E-Mail Removed)> wrote in message
news:1C95A1B8-95C8-4457-BDC5-(E-Mail Removed)...
> Hello
> Access 2003.
>
> I have this code which works well. However, I would like to display only
> year (yyyy) in textStart rather than day/month/year. Could you help me
> how
> to do it?
>
> txtStart Default Value : Date()
>
> Private Sub bAddYear_Click()
> Select Case Me.fraOptions.Value
> Case Is = 1
> Me.txtStart.Value = DateAdd("yyyy", 1, [txtStart])
> Case Is = 2
> Me.txtStart.Value = DateAdd("yyyy", 5, [txtStart])
> Case Is = 3
> Me.txtStart.Value = DateAdd("yyyy", 10, [txtStart])
> End Select
>
> Thanks in advance



If you set the Format property of txtStart to "yyyy" (without the quotes),
the text box will just display the year. Note that the *value* of the text
box will still be a complete date; it's just the way it is displayed that
will be different. And if the user edits the text box, it is the date
value, not just the year, that will be displayed and edited.

If what you really want is just to put a year in the text box, then you need
to set and increment its value differently.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to display only year as date in txtbox sebastico Microsoft Access VBA Modules 6 18th May 2010 08:17 PM
Converting Day, Date Month Year format to MM/DD/YYYY 61Petrus Microsoft Excel Worksheet Functions 1 19th Feb 2008 08:47 PM
Adding 1 year's difference to user's input of yyyy-yyyy? StargateFanFromWork Microsoft Excel Discussion 3 29th May 2007 05:25 PM
How do I query a Date field (mm/dd/yyyy) by a Year (yyyy) value. Wayne Microsoft Access Queries 2 23rd Feb 2006 12:24 AM
Year=DateDiff(yyyy,Now()-[Entry Date]) Why not work? Access =?Utf-8?B?TWFyaWFUaG8=?= Microsoft Access Getting Started 4 2nd Oct 2005 11:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:44 PM.