ACC2000: How to Force Access to Display Dates with Four-Digit YearsID: Q214701
|
Microsoft Access has two options that force Date fields and controls to display four-digit years. One option (This database) forces the display of four-digit years at the database-level in a particular database or project. The other option (All databases) forces the display of four-digit years at the application-level in all databases and projects.
The reason for these options is to make sure the user is aware of which century is used. These options only affect the format of the date. Access stores dates as serial numbers. For example, when you type the date 4/16/50 (April 16, 1950) it is actually stored as the serial number 18369. The date April 16, 2050 is stored as the serial number 54894.
To access these two options from the user interface, on the Tools menu, click Options, and then click the General tab. In the Use four-digit year formatting area, the This database check box controls the database-level option and the All databases check box controls the application-level option.
If either of these options is set, Access overrides the specified date format to show a four-digit year. The year portion of the date is the only part affected. Other parts of the date still rely on the Windows Regional Settings and Date formats.
The database-level option is stored in the Microsoft Access database (MDB) or Microsoft Access project (ADP). This allows developers to deliver year 2000-compliant applications regardless of the user's Regional Settings.
The application-level option is stored in the Windows Registry with all the other Access settings. This allows administrators to force all Access applications on the computer to use four-digit years, regardless of the Regional Settings, Date formats, or the database-level option.
You can programmatically check or set these options with the GetOption and SetOption methods respectively.
Microsoft provides programming examples for illustration only, without warranty
either expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals can help explain the functionality
of a particular procedure, but they will not modify these examples to provide added
functionality or construct procedures to meet your specific needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/overview/overview.aspUse the following segment of code to determine the current database-level setting:
If GetOption("Four-Digit Year Formatting") = True Then
MsgBox "This database is using four-digit year formatting."
Else
MsgBox "This database is not using four-digit year formatting."
End If
The following segment of code forces Access to use four-digit year formatting at the database-level:
SetOption "Four-Digit Year Formatting", True
The following segment of code determines the current application-level setting:
If GetOption("Four-Digit Year Formatting All Databases") = True Then
MsgBox "Access is using four-digit year formatting."
Else
MsgBox "Access is not using four-digit year formatting."
End If
The following segment of code forces Access to use four-digit year formatting at the application-level:
SetOption "Four-Digit Year Formatting All Databases", True
For additional information about dates in Access, please see the following
article in the Microsoft Knowledge Base:
Q208339 ACC2000: Years 00-29 Default to Year 2000 When Typed as M/D/YY
For more information about the GetOption and SetOption methods, in the Visual Basic Editor, click
Microsoft Visual Basic Help on the Help menu, type "GetOption, SetOption methods" in
the Office Assistant or the Answer Wizard, and then click Search to
view the topic.
For more information about how Microsoft products are affected by year 2000
(Y2K) issues, please see the following Microsoft World Wide Web site:
http://www.microsoft.com/year2000/
Additional query words: inf Y2K KB2000 millennium
Keywords : kbdta kb2000
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: July 6, 1999