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 / May 2007

Tip: Looking for answers? Try searching our database.

YEAR Only

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dan @BCBS - 23 May 2007 13:41 GMT
I would like to return only the YEAR in a Text Box on a form.
I tried adding this to the Text Box but it still returns the mm/dd/yyyy

Private Sub TR_CLOSEDATE_BeforeUpdate(Cancel As Integer)
Dim LYear As Integer

LYear = Year(TR_CLOSEDATE)
End Sub

Suggestions
Graham R Seach - 23 May 2007 14:11 GMT
Dan,

Enter the following into the textbox's Format property:
   yyyy

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

>I would like to return only the YEAR in a Text Box on a form.
> I tried adding this to the Text Box but it still returns the mm/dd/yyyy
[quoted text clipped - 6 lines]
>
> Suggestions
Al Campagna - 23 May 2007 14:27 GMT
Dan,
   Well, you'll need to rethink this setup a bit....
   Since you capture TR_CLOSEDATE, there's no need to "capture" the Year of that date.

   Don't store a value in a table that can be derived/caculated at any time "on the fly"
from values you already have.

   Given an ubound text control on the form called LYear (formatted for whole numbers (#)
with no decimals) this ControlSource will always "display" the correct Year...
       = Year(TR_CLOSEDATE)

   You would use the same method in any subsequent form, query, or report to "regenerate"
the Year, when you need it.
Signature

hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."

>I would like to return only the YEAR in a Text Box on a form.
> I tried adding this to the Text Box but it still returns the mm/dd/yyyy
[quoted text clipped - 6 lines]
>
> Suggestions
missinglinq - 23 May 2007 14:37 GMT
How are you placing the value in the textbox? The code you posted only
assigns the year to a variable, LYear, not a textbox. Assuming TR_CloseDate
is a valid date, Year(TR_CloseDate) should yield the year.

Signature

There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

 
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.