Knowledge Base

TMGR: Using Literal Date Symbol # May Cause Run-time Error

Article ID: 149880

Article Last Modified on 12/30/2005


APPLIES TO


This article was previously published under Q149880

SYMPTOMS

You may receive the following error message when you enclose literal dates with the number sign characters (#) and pass an argument to a property or a method, for example, #January 1, 01# or #1 Jan 01# for the date 1/1/2001:
Run-time error '1':

There was an OLE automation error.

CAUSE

When you enter a literal date, such as #1/1/00#, where you specify only the last two digits of the year, Visual Basic for Applications interprets the years 00-50 as years 1900-1950. If the year for a literal date is in that range, a run-time error occurs because valid dates for Microsoft Team Manager are from 1/1/1984 to 12-31-2050.

WORKAROUND

You can use one of the following methods to work around this behavior:

  1. Use four digits to specify the year, for example, #1/1/2000#.
  2. Use a quoted string to represent your dates instead of a literal date, for example, "1/1/00".
  3. Use the Visual Basic for Applications CStr function to convert the literal date to string, for example, CStr(#1/1/00#).

Additional query words: 1.00

Keywords: kberrmsg KB149880