Microsoft Y2K  
Microsoft
 This static CD-based web site is representative of the www.microsoft.com/y2k site as of October 15, 1999.

Microsoft Year 2000 Readiness Disclosure & Resource Center
Preparing Office Solutions for the Year 2000
Operating System and BIOS Issues

The system that your application runs on is comprised of a computer and operating system. You must take steps to ensure that there are no Year 2000 issues in this area before starting with the Access application itself.

The BIOS

The original IBM PC was designed back in 1984. The core problem is that many older personal computers have BIOS systems that won't correctly interpret the change of the century. On these older systems, the real-time clock implemented in CMOS (that battery maintained memory chip that keeps all your BIOS settings, including the date) only has two digits to store the year in.

This problem manifests itself as follows: when the year 2000 rolls around, the clock resets itself to the year 1900. When this happens, the BIOS interprets the year as invalid, and sets the system clock to March 1st, 1980, which is the first valid date as far as the BIOS is concerned.

Modern personal computers do not have this problem because the BIOS code applies a "windowing" technique that allows the computer to correctly assume the century.

So how do you determine which machines are affected by this "old BIOS" problem? You can easily check your machine because the steps are fairly simple.

Warning   Setting the clock forward on your computer may seem to be a harmless action, but it can have disastrous effects if you aren't aware of all the issues. When setting the clock forward, even for a brief time, be sure to take the following into account:

  • Beta software usually times out after a certain date. The same holds for trial software and license-dated software.
  • If your clock is set ahead, will your email/newsgroup software send messages with the incorrect date and time? This can wreak havoc on your recipient's inbox.

To check your machine (only after heeding the above warning):

  1. Close all running programs.
  2. Use the DOS DATE command to set your date to 12/31/1999.
  3. Use the DOS Time command to set your time to 11:58:00 PM.
  4. Wait a few minutes until the clock rolls over to 01/01/2000.
  5. Check your date and time settings. You should see 01/01/2000. If not, your BIOS needs to be updated.
  6. Shut down Windows and turn your computer off.
  7. Wait a few minutes and turn your computer back on and boot to a DOS prompt.
  8. Check the date and time settings. You should see 01/01/2000. If not, your BIOS need to be updated.

There are several BIOS checking programs available also. For more information consult the Year 2000 resource center (http://www.microsoft.com/technet/year2k/tools/tools.htm).

Control Panel Date Settings

The Windows Control Panel exposes a number of settings under the heading of "Regional Settings". These settings allow you to customize the default date and time formats to be used by your applications. Many Windows applications take these settings into account. Unfortunately they take their value from the Short Date setting, which by default is set to a format that only supports a two-digit year. For example, on U.S. versions of Windows, the default is "m/d/yy", which means that any part of your application that does not have an explicit date format enforced will use the Control Panel default of two digit years.

Because if this, it is commonly believed that you can solve the Year 2000 problem on the desktop simply by setting the Short Date format to include four digit years. Unfortunately, this is not a complete solution for a number of reasons. The first is that most custom routines in applications do not use the short date setting. Look through your application's code and see if you can find a single place where you are actually using routines to check or set the short date format. Chances are, there are no such occurrencesùwhich means that fiddling with the Control Panel settings isn't the solution. Secondly, and perhaps more importantly, there is nothing to stop your application's users from setting or changing the short date format on their own. After all, it is easier to type in two digit years.

Programmatically Detecting and Changing Control Panel Settings

As an extra safety net for your application, you may want to have it set the Short Date format at the start of your program. This ensures that any place where Access, VB or Excel uses the setting will be correct. If your application does need to read or set the short date format, you can use the following code.

Declare Function GetProfileString Lib "KERNEL" (ByVal strSection As String, ByVal strKeyName As String, ByVal strDefault As String, ByVal strReturned As String, ByVal intSize As Integer) As Integer

Declare Function WriteProfileString Lib "KERNEL" (ByVal strSection As String, ByVal strKeyName As String, ByVal strValue As String) As Integer

Function SetCurrentShortDate (strIn As String) As String
   ' Comments : Sets the control panel short date setting
   ' Parameters: strIn - format to use, e.g. mm/dd/yyyy
   ' Returns : new value or <error>
   Dim fOK As Integer

   fOK = WinINIWriteSetting_Y2K("intl", "sshortdate", strIn)

   If fOK Then
    SetCurrentShortDate = strIn
   Else
    SetCurrentShortDate = "<error>"
   End If

End Function

Function ShowCurrentShortDate_Y2K () As String
   ' Comments : Returns the current control panel short date setting
   ' Parameters: none
   ' Returns : string

ShowCurrentShortDate_Y2K = WinINIGetSetting_Y2K("intl", "sshortdate")

End Function

Function WinINIGetSetting_Y2K (strSection As String, strKeyName As String) As String
   ' Comments : Returns a string value from the WIN.INI file
   ' Parameters: strSection - name of the section to look in
   '     strKeyName - name of the key to look for
   ' Returns : string value
   '
   Dim strBuffer As String * 256
   Dim intSize As Integer

   intSize = GetProfileString(strSection, strKeyName, "", strBuffer, 256)

   WinINIGetSetting_Y2K = Left$(strBuffer, intSize)

End Function

Function WinINIWriteSetting_Y2K (strSection As String, strKeyName As String, strValue As String) As Integer
   ' Comments : writes the specified value to WIN.INI
   ' Parameters: strSection - section to write into
   '     strKeyName - key to write into
   '     strValue - value to write
   ' Returns : True if successful, False otherwise
   '
   Dim intStatus As Integer

   intStatus = WriteProfileString(strSection, strKeyName, strValue)

   WinINIWriteSetting_Y2K = (intStatus <> 0)

End Function

Code Listing 4   16-Bit Code (Access 2 and VB 3) for Getting/Setting the

The following code is the VBA (32-bit) version.

Private Declare Function GetProfileString _
   Lib "kernel32" _
   Alias "GetProfileStringA" _
   (ByVal strSection As String, _
   ByVal strKeyName As String, _
   ByVal strDefault As String, _
   ByVal strReturned As String, _
   ByVal intSize As Long) _
   As Long
   
Private Declare Function WriteProfileString _
   Lib "kernel32" _
   Alias "WriteProfileStringA" _
   (ByVal strSection As String, _
   ByVal strKeyName As String, _
   ByVal strValue As String) _
   As Long
Procedures

Private Function WinINIWriteSetting( _
   strSection As String, _
   strKeyName As String, _
   strValue As String) _
   As Integer
   ' Comments : Writes the specified value to WIN.INI
   ' Parameters: strSection - Section to write into
   '     strKeyName - Key to write into
   '     strValue - Value to write
   ' Returns : True if successful, False otherwise
   '
Dim lngStatus As Long

   lngStatus = WriteProfileString(strSection, strKeyName, strValue)

   WinINIWriteSetting = (lngStatus <> 0)

PROC_EXIT:
   Exit Function

PROC_ERR:
   MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
   "WinINIWriteSetting"
   Resume PROC_EXIT

End Function

Private Function WinINIGetSetting( _
   strSection As String, _
   strKeyName As String) _
   As String
   ' Comments : Returns a string value from the WIN.INI file
   ' Parameters: strSection - Name of the section to look in
   '     strKeyName - Name of the key to look for
   ' Returns : String value
   '
   Dim strBuffer As String * 256
   Dim intSize As Integer

   On Error GoTo PROC_ERR

   intSize = GetProfileString( _
     strSection, strKeyName, "", strBuffer, 256)

   WinINIGetSetting = Left$(strBuffer, intSize)

PROC_EXIT:
   Exit Function

PROC_ERR:
   MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
   "WinINIGetSetting"
   Resume PROC_EXIT

End Function

Public Function ShowCurrentShortDate() As String
   ' Comments : Returns the current control panel short date setting
   ' Parameters: None
   ' Returns : String
   '
On Error GoTo PROC_ERR

   ShowCurrentShortDate = WinINIGetSetting("intl", "sshortdate")

PROC_EXIT:
   Exit Function

PROC_ERR:
   MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
   "ShowCurrentShortDate"
   Resume PROC_EXIT

End Function

Public Function SetShortDateFormat(strIn As String) As String
   ' Comments : Sets the control panel short date setting
   ' Parameters: strIn - Format to use, e.g. mm/dd/yyyy
   ' Returns : New value or <error>
   '
   Dim fOk As Integer

   On Error GoTo PROC_ERR

   fOk = WinINIWriteSetting("intl", "sshortdate", strIn)

   If fOk Then
     SetShortDateFormat = strIn
   Else
     SetShortDateFormat = "<error>"
   End If

PROC_EXIT:
   Exit Function

PROC_ERR:
   MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
   "SetShortDateFormat"
   Resume PROC_EXIT

End Function

Code Listing 5   VBA Code for Getting/Setting the Short Date Format

<< 1 2 3 4 5 6 7 8 9 10 11 12 13 14 >>


Send This To a Friend


 

Tuesday, March 16, 1999
1998 Microsoft Corporation. All rights reserved. Terms of use.

This site is being designated as a Year 2000 Readiness Disclosure and the information contained herein is provided pursuant to the terms hereof and the Year 2000 Information and Readiness Disclosure Act.