Copyright: Calendar Control


Calendar Control

The Calendar Control displays a monthly calendar that you can insert in a Microsoft Access form.

Filename

Msacal70.ocx

Remarks

The Calendar Control supports properties that you can use to set and retrieve the date and to control the appearance of the calendar. The calendar supports methods that you can use to set the appropriate day, month, and year, to show an About box, and to repaint the calendar. The calendar also supports events that notify your application when the user has moved to a new date on the calendar, when the user has clicked or double-clicked on a date, and when the user has pressed a key.


Calendar Control Properties

The following table describes the properties for the Calendar Control.

Property	Description
BackColor	The background color for the Calendar Control.
Day	The current day of the month.
DayFont	The font used to display the days of the week in the Calendar Control.
DayFontColor	The color to use when displaying the days of the week.
DayLength	The type of format used to display days of the week. Use M/T/W, Mon/Tue/Wed, or Monday/Tuesday/Wednesday format.
FirstDay	The first day of the week that appears in the Calendar Control.
GridCellEffect	The type of format used to display the calendar. Use the Flat, Sunken, or Raised format.
GridFont	The font used to display the days of the month in the grid.
GridFontColor	The color to use when displaying the days of the month.
GridLinesColor	The grid line color for a flat format calendar.
Month	The current month.
MonthLength	The type of format used to display months of the year. Use Jan/Feb/Mar or January/February/March format.
ShowDateSelectors	The visibility of the month and year combo box selectors.
ShowDays	The visibility of the days of the week.
ShowHorizontalGrid	The visibility of the horizontal grid lines for a flat calendar.
ShowTitle	The visibility of the month/year title.
ShowVerticalGrid	The visibility of the vertical grid lines for a flat calendar.
TitleFont	The font used to display the month/year title above the calendar grid.
TitleFontColor	The color to use when displaying the month/year title.
Value	The date value that corresponds to the selected date in the Calendar Control.
ValueIsNull	The appearance of the current date as highlighted or not highlighted.
Year	The current year.
For information on Microsoft Access properties that apply to the Calendar Control, see Microsoft Access Language Elements That Apply to Custom Controls.

For information on using these properties in the Calendar Control, see the individual property topics and Using the Properties, Methods, and Events of a Custom Control.

For information on using the Calendar Control custom property sheet, see Using a Custom Control's Custom Property Sheet.


Calendar Control Methods

The following table describes the methods for the Calendar Control.

Method	Description
AboutBox	Displays the version and copyright information.
NextDay	Increments the day, resets the month (if the current day is the last day of the month), and repaints the calendar.
NextMonth	Increments the month, resets the year (if the current month is December), and repaints the calendar.
NextWeek	Increments the week, resets the month and year (as necessary), and repaints the calendar.
NextYear	Increments the year and repaints the calendar.
PreviousDay	Decrements the day, resets the month (if the current day is the first day of the month), and repaints the calendar.
PreviousMonth	Decrements the month, resets the year (if the current month is January), and repaints the calendar.
PreviousWeek	Decrements the week, resets the month and year (as necessary), and repaints the calendar.
PreviousYear	Decrements the year and repaints the calendar.
Refresh	Repaints the calendar.
Today	Sets the current date to today's date.
For information on using these methods in the Calendar Control, see the individual method topics and Using the Properties, Methods, and Events of a Custom Control.


Calendar Control Events

The following table describes the events for the Calendar Control.

Event	Description
AfterUpdate	Occurs after the user moves to a new date in the Calendar Control and after the calendar has been repainted.
BeforeUpdate	Occurs after the user moves to a new date in the Calendar Control but before the calendar has been redrawn.
Click	Occurs when the user clicks a date in the Calendar Control.
DblClick	Occurs when the user double-clicks a date in the Calendar Control.
KeyDown	Occurs when the user presses a key while the Calendar Control has the focus.
KeyPress	Occurs when the user presses and releases an ANSI key while the Calendar Control has the focus.
KeyUp	Occurs when the user releases a key while the Calendar Control has the focus.
NewMonth	Occurs when the Calendar Control date changes to a new month.
NewYear	Occurs when the Calendar Control date changes to a new year.
For information on Microsoft Access events that apply to the Calendar Control, see Microsoft Access Language Elements That Apply to Custom Controls.

For information on using these events in the Calendar Control, see the individual event topics and Using the Properties, Methods, and Events of a Custom Control.


Calendar Control Example Reference

The following table identifies examples of the Calendar Control methods.

Method	Description
Refresh	Demonstrates repainting the Calendar Control.
FirstDay	Demonstrates setting the first day.
NextDay	Demonstrates setting the next day.
NextWeek	Demonstrates setting the next week.
NextMonth	Demonstrates setting the next month.
NextYear	Demonstrates setting the next year.
PreviousDay	Demonstrates setting the previous day.
PreviousWeek	Demonstrates setting the previous week.
PreviousMonth	Demonstrates setting the previous month.
PreviousYear	Demonstrates setting the previous year.


BackColor Property (Calendar Control)

You can use the BackColor property to specify the background color that appears in the Calendar Control.

Syntax

controlname[.Object].BackColor [ = color ]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The BackColor property uses the following setting.

Setting	Property Sheet	Visual Basic
color	Select a color in the Colors tab of the Calendar Control custom property sheet, or enter a number that represents an RGB color in the Microsoft Access property sheet.	A Long Integer data type that represents an RGB color.
You can set this property in the Calendar Control custom property sheet, in the Microsoft Access property sheet, in a macro, or in Visual Basic.

Remarks

The valid range for a normal RGB color is 0 to 16,777,215 (&HFFFFFF). The high byte of a number in this range equals 0; the lower three bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (&HFF).

If the high byte is not 0 (the number is negative), Microsoft Access uses the system colors, as defined in the user's Windows Control Panel. Microsoft Windows provides a set of negative numbers that correspond to various parts of an application's window (for example, the window frame, or the title bar text). You can set the BackColor property to one of these numbers, and Microsoft Access will use the color you've selected for this part of the window. For more information, see Set color properties to Microsoft Windows system colors. The Colors tab in the Calendar Control custom property sheet has a System Color box where you can select a system color for this property.


Day Property

You can use the Day property to set the current day of the month in the Calendar Control.

Syntax

controlname[.Object].Day [ = day ]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The Day property uses the following setting.

Setting	Property Sheet	Visual Basic
day	Set the property to the day of the month you want in the Microsoft Access property sheet.	An Integer data type value representing the day of the month, from 1 to 31 depending on the month and year.
You can set this property in the Microsoft Access property sheet, in a macro, or in Visual Basic.


DayFont Property

You can use the DayFont property to specify the font used when displaying the days of the week in the Calendar Control.

Syntax

controlname[.Object].DayFont [ = name ]

controlname[.Object].DayFont.Name [ = name ]

controlname[.Object].DayFont.Size [ = size ]

controlname[.Object].DayFont.Bold [ = bold ]

controlname[.Object].DayFont.Italic [ = italic ]

controlname[.Object].DayFont.Underline [ = underline ]

controlname[.Object].DayFont.Strikethrough [ = strikethrough ]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The DayFont property uses the following settings.

Setting	Property Sheet	Visual Basic
name	Select a font from the Font box list in the Fonts tab of the Calendar Control custom property sheet.	A string expression representing the font name, such as "MS Sans Serif" or "Times New Roman".
size	Enter or select a font size in the Size box in the Fonts tab of the Calendar Control custom property sheet.	A numeric expression representing the font size, such as 8, 10, or 12.
bold	Select Regular, Bold, or Bold Italic in the Font Style box in the Fonts tab of the Calendar Control custom property sheet.	A boolean expression (True or False) representing whether or not to use a boldface font.
italic	Select Regular, Italic, or Bold Italic in the Font Style box in the Fonts tab of the Calendar Control custom property sheet.	A boolean expression (True or False) representing whether or not to use an italic (slanted) font.
underline	Check or uncheck the Underline box in the Effects option group in the Fonts tab of the Calendar Control custom property sheet.	A boolean expression (True or False) representing whether or not to underline the font.
strikethrough	Check or uncheck the Strikeout box in the Effects option group in the Fonts tab of the Calendar Control custom property sheet.	A boolean expression (True or False) representing whether or not to use a strikethrough font, drawing a line through the center of the text.
You can set this property in the Calendar Control custom property sheet, in a macro, or in Visual Basic. You can't set it in the Microsoft Access property sheet.

Remarks

The days of the week are displayed in the first row of the Calendar Control, below the month/year title. You can use the ShowDays property to determine whether the days of the week are displayed, and the ShowTitle property to determine whether the month/year title is displayed. You can use the DayFontColor property to set the color for the days of the week.

The default property for a font is its name, so setting the DayFont property in a macro or Visual Basic is identical to setting the DayFont.Name property.


DayFontColor Property

You can use the DayFontColor property to specify the color used when displaying the days of the week in the Calendar Control.

Syntax

controlname[.Object].DayFontColor [ = color ]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The DayFontColor property uses the following setting.

Setting	Property Sheet	Visual Basic
color	Select a color in the Colors tab of the Calendar Control custom property sheet, or enter a number that represents an RGB color in the Microsoft Access property sheet.	A Long Integer data type that represents an RGB color.
You can set this property in the Calendar Control custom property sheet, in the Microsoft Access property sheet, in a macro, or in Visual Basic.

Remarks

The days of the week are displayed in the first row of the Calendar Control, below the month/year title. You can use the ShowDays property to determine whether the days of the week are displayed, and the ShowTitle property to determine whether the month/year title is displayed. You can use the DayFont property to set the font for the days of the week.

The valid range for a normal RGB color is 0 to 16,777,215 (&HFFFFFF). The high byte of a number in this range equals 0; the lower three bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (&HFF).

If the high byte is not 0 (the number is negative), Microsoft Access uses the system colors, as defined in the user's Windows Control Panel. Microsoft Windows provides a set of negative numbers that correspond to various parts of an application's window (for example, the window frame, or the title bar text). You can set the DayFontColor property to one of these numbers, and Microsoft Access will use the color you've selected for this part of the window. For more information, see Set color properties to Microsoft Windows system colors. The Colors tab in the Calendar Control custom property sheet has a System Color box where you can select a system color for this property.


DayLength Property

You can use the DayLength property to determine how the days of the week in the Calendar Control are displayed (in short, medium, or long format).

Syntax

controlname[.Object].DayLength = [ length ]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The DayLength property uses the following setting.

Setting	Property Sheet	Visual Basic
length	Select Short, Medium, or Long from the drop-down list in the General tab of the Calendar Control custom property sheet or from the drop-down list for this argument in the Microsoft Access property sheet.	A numeric expression representing the format to use when displaying the days of the week. The numeric values map to the formats as follows.
	Short for S, M, T, W, T, F, S	0     Short
	Medium for Sun, Mon, Tue, Wed, Thu, Fri, Sat	1     Medium
	Long for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday	2      Long
You can set this property in the Calendar Control custom property sheet, in the Microsoft Access property sheet, in a macro, or in Visual Basic.

Remarks

The days of the week are displayed in the first row of the Calendar Control, below the month/year title. You can use the ShowDays property to determine whether the days of the week are displayed, and the ShowTitle property to determine whether the month/year title is displayed. You can use the DayFont property and the DayFontColor property to set the font and the font color for the days of the week.


FirstDay Property

You can use the FirstDay property to determine the first day of the week, as displayed in the first column of the Calendar Control.

Syntax

controlname[.Object].FirstDay = [ day ]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The FirstDay property uses the following setting.

Setting	Property Sheet	Visual Basic
day	Select a day of the week from the drop-down list in the General tab of the Calendar Control custom property sheet or from the drop-down list for this argument in the Microsoft Access property sheet.	A numeric expression representing a day of the week. The numeric values map to the days of the week as follows.
		1     Sunday
		2     Monday
		3     Tuesday
		4     Wednesday
		5     Thursday
		6     Friday
		7     Saturday
You can set this property in the Calendar Control custom property sheet, in the Microsoft Access property sheet, in a macro, or in Visual Basic.

Remarks

The first column displayed in the Calendar Control corresponds to the value specified. For example, if the value is "Monday", the first column represents Monday. The days of the week are displayed in the first row of the Calendar Control, below the month/year title. You can use the ShowDays property to determine whether the days of the week are displayed, and the ShowTitle property to determine whether the month/year title is displayed.


GridFont Property

You can use the GridFont property to specify the font used when displaying the days of the month in the grid of the Calendar Control.

Syntax

controlname[.Object].GridFont [ = name ]

controlname[.Object].GridFont.Name [ = name ]

controlname[.Object].GridFont.Size [ = size ]

controlname[.Object].GridFont.Bold [ = bold ]

controlname[.Object].GridFont.Italic [ = italic ]

controlname[.Object].GridFont.Underline [ = underline ]

controlname[.Object].GridFont.Strikethrough [ = strikethrough ]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The GridFont property uses the following settings.

Setting	Property Sheet	Visual Basic
name	Select a font from the Font box list in the Fonts tab of the Calendar Control custom property sheet.	A string expression representing the font name, such as "MS Sans Serif" or "Times New Roman".
size	Enter or select a font size in the Size box in the Fonts tab of the Calendar Control custom property sheet.	A numeric expression representing the font size, such as 8, 10, or 12.
bold	Select Regular, Bold, or Bold Italic in the Font Style box in the Fonts tab of the Calendar Control custom property sheet.	A boolean expression (True or False) representing whether or not to use a boldface font.
italic	Select Regular, Italic, or Bold Italic in the Font Style box in the Fonts tab of the Calendar Control custom property sheet.	A boolean expression (True or False) representing whether or not to use an italic (slanted) font.
underline	Check or uncheck the Underline box in the Effects option group in the Fonts tab of the Calendar Control custom property sheet.	A boolean expression (True or False) representing whether or not to underline the font.
strikethrough	Check or uncheck the Strikeout box in the Effects option group in the Fonts tab of the Calendar Control custom property sheet.	A boolean expression (True or False) representing whether or not to use a strikethrough font, drawing a line through the center of the text.
You can set this property in the Calendar Control custom property sheet, in a macro, or in Visual Basic. You can't set it in the Microsoft Access property sheet.

Remarks

You can use the GridFontColor property to set the color for the days of the month.

The default property for a font is its name, so setting the GridFont property in a macro or Visual Basic is identical to setting the GridFont.Name property.


GridFontColor Property

You can use the GridFontColor property to specify the color used when displaying the days of the month in the grid of the Calendar Control.

Syntax

controlname[.Object].GridFontColor [ = color ]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The GridFontColor property uses the following setting.

Setting	Property Sheet	Visual Basic
color	Select a color in the Colors tab of the Calendar Control custom property sheet, or enter a number that represents an RGB color in the Microsoft Access property sheet.	A Long Integer data type that represents an RGB color.
You can set this property in the Calendar Control custom property sheet, in the Microsoft Access property sheet, in a macro, or in Visual Basic.

Remarks

The valid range for a normal RGB color is 0 to 16,777,215 (&HFFFFFF). The high byte of a number in this range equals 0; the lower three bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (&HFF).

If the high byte is not 0 (the number is negative), Microsoft Access uses the system colors, as defined in the user's Windows Control Panel. Microsoft Windows provides a set of negative numbers that correspond to various parts of an application's window (for example, the window frame, or the title bar text). You can set the GridFontColor property to one of these numbers, and Microsoft Access will use the color you've selected for this part of the window. For more information, see Set color properties to Microsoft Windows system colors. The Colors tab in the Calendar Control custom property sheet has a System Color box where you can select a system color for this property.

You can use the GridFont property to set the font for the days of the month.


GridLinesColor Property

You can use the GridLinesColor property to specify the color used when displaying the lines in the grid of a flat Calendar Control.

Syntax

controlname[.Object].GridLinesColor [ = color ]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The GridLinesColor property uses the following setting.

Setting	Property Sheet	Visual Basic
color	Select a color in the Colors tab of the Calendar Control custom property sheet, or enter a number that represents an RGB color in the Microsoft Access property sheet.	A Long Integer data type that represents an RGB color.
You can set this property in the Calendar Control custom property sheet, in the Microsoft Access property sheet, in a macro, or in Visual Basic.

Remarks

The GridLinesColor property sets the color for the gridlines for a flat calendar only (a Calendar Control whose GridCellEffect property is set to "Flat").

The valid range for a normal RGB color is 0 to 16,777,215 (&HFFFFFF). The high byte of a number in this range equals 0; the lower three bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (&HFF).

If the high byte is not 0 (the number is negative), Microsoft Access uses the system colors, as defined in the user's Windows Control Panel. Microsoft Windows provides a set of negative numbers that correspond to various parts of an application's window (for example, the window frame, or the title bar text). You can set the GridLinesColor property to one of these numbers, and Microsoft Access will use the color you've selected for this part of the window. For more information, see Set color properties to Microsoft Windows system colors. The Colors tab in the Calendar Control custom property sheet has a System Color box where you can select a system color for this property.


GridCellEffect Property

You can use the GridCellEffect property to specify the effect used when displaying the grid of the Calendar Control.

Syntax

controlname[.Object].GridCellEffect [ = effect ]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The GridCellEffect property uses the following setting.

Setting	Property Sheet	Visual Basic
effect	Select Flat, Raised, or Sunken from the drop-down list in the General tab of the Calendar Control custom property sheet or from the drop-down list for this argument in the Microsoft Access property sheet.	A numeric expression representing the effect used when displaying the grid of the Calendar Control. The numeric values map to the effects as follows.
		0     Flat
		1     Raised
		2     Sunken
You can set this property in the Calendar Control custom property sheet, in the Microsoft Access property sheet, in a macro, or in Visual Basic.

Remarks

When the GridCellEffect property is set to "Flat", you can also set the GridLinesColor, ShowHorizontalGrid, and ShowVerticalGrid properties.


Month Property

You can use the Month property to set the current month to display in the Calendar Control.

Syntax

controlname[.Object].Month = [ month ]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The Month property uses the following setting.

Setting	Property Sheet	Visual Basic
month	Set the property to the month you want in the Microsoft Access property sheet. Use an integer value to denote the month, as shown in the Visual Basic section of this table.	An Integer value representing the month to display within the current year.
		1   January
		2   February
		3   March
		4   April
		5   May
		6   June
		7   July
		8   August
		9   September
		10   October
		11   November
		12   December
You can set this property in the Microsoft Access property sheet, in a macro, or in Visual Basic.

Remarks

When the month changes, the year remains the same, and the day remains the same if possible. If the current day is beyond the last day of the new month, the day changes to the last day of the new month.


MonthLength Property

You can use the MonthLength property to determine how months are displayed in the month/year title in the Calendar Control (in short or long format).

Syntax

controlname[.Object].MonthLength = [ length ]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The MonthLength property uses the following setting.

Setting	Property Sheet	Visual Basic
length	Select Short or Long from the drop-down list in the General tab of the Calendar Control custom property sheet or from the drop-down list for this argument in the Microsoft Access property sheet.	A numeric expression representing the format to use when displaying months. The numeric values map to the formats as follows.
	Short for Jan, Feb, Mar, etc.	0     Short
	Long for January, February, March, etc.	2     Long
You can set this property in the Calendar Control custom property sheet, in the Microsoft Access property sheet, in a macro, or in Visual Basic.

Remarks

The month/year title is displayed at the top of the Calendar Control, above the days of the week, and next to the month combo box. You can use the ShowTitle property to determine whether the month/year title is displayed, the ShowDateSelectors property to determine whether the month and year combo boxes are displayed, and the ShowDays property to determine whether the days of the week are displayed. You can use the TitleFont property and the TitleFontColor property to set the font and the font color for the month/year title.


ShowDateSelectors Property

You can use the ShowDateSelectors property to determine whether or not to display the combo box selectors for month and year that appear above the calendar grid.

Syntax

controlname[.Object].ShowDateSelectors = [ show ]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The ShowDateSelectors property uses the following setting.

Setting	Property Sheet	Visual Basic
show	Check or uncheck the Month/Year Selectors box in the Show option group in the General tab of the Calendar Control custom property sheet, or select Yes or No from the drop-down list for this argument in the Microsoft Access property sheet.	A boolean value (True or False) representing whether or not to display combo box selectors for month and year.
You can set this property in the Calendar Control custom property sheet, in the Microsoft Access property sheet, in a macro, or in Visual Basic.

Remarks

Without the combo box selectors, you can still set the month and year using the PreviousMonth, NextMonth, PreviousYear, and NextYear methods and their corresponding keyboard equivalents.

When printing the Calendar Control, the date selectors are never printed, regardless of the ShowDateSelectors setting.


ShowDays Property

You can use the ShowDays property to determine whether or not to display the days of the week in the Calendar Control.

Syntax

controlname[.Object].ShowDays = [ show ]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The ShowDays property uses the following setting.

Setting	Property Sheet	Visual Basic
show	Check or uncheck the Days of Week box in the Show option group in the General tab of the Calendar Control custom property sheet, or select Yes or No from the drop-down list for this argument in the Microsoft Access property sheet.	A boolean value (True or False) representing whether or not to show the days of the week.
You can set this property in Calendar Control custom property sheet, in the Microsoft Access property sheet, in a macro, or in Visual Basic.

Remarks

The days of the week are displayed in the first row of the Calendar Control, below the month/year title. You can use the ShowDays property to determine whether the days of the week are displayed, and the ShowTitle property to determine whether the month/year title is displayed. You can use the DayFont property and the DayFontColor property to set the font and the font color for the days of the week.


ShowHorizontalGrid Property

You can use the ShowHorizontalGrid property to determine whether or not to display horizontal gridlines between each week in a flat Calendar Control.

Syntax

controlname[.Object].ShowHorizontalGrid = [ show ]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The ShowHorizontalGrid property uses the following setting.

Setting	Property Sheet	Visual Basic
show	Check or uncheck the Horizontal Gridlines box in the Show option group in the General tab of the Calendar Control custom property sheet, or select Yes or No from the drop-down list for this argument in the Microsoft Access property sheet.	A boolean value (True or False) representing whether or not to show the horizontal gridlines for a flat Calendar Control.
You can set this property in the Calendar Control custom property sheet, in the Microsoft Access property sheet, in a macro, or in Visual Basic.

Remarks

The ShowHorizontalGrid property has no effect unless the GridCellEffect property is set to "Flat".


ShowTitle Property

You can use the ShowTitle property to determine whether or not to display the month/year title above the calendar grid.

Syntax

controlname[.Object].ShowTitle = [ show]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The ShowTitle property uses the following setting.

Setting	Property Sheet	Visual Basic
show	Check or uncheck the Month/Year Title box in the Show option group in the General tab of the Calendar Control custom property sheet, or select Yes or No from the drop-down list for this argument in the Microsoft Access property sheet.	A boolean value (True or False) representing whether or not to display the month/year title.
You can set this property in the the Calendar Control custom property sheet, in the Microsoft Access property sheet, in a macro, or in Visual Basic.

Remarks

The month/year title is displayed at the top of the Calendar Control, above the days of the week, and next to the month combo box. You can use the ShowDateSelectors property to determine whether the month and year combo boxes are displayed, and the ShowDays property to determine whether the days of the week are displayed. You can use the TitleFont property and the TitleFontColor property to set the font and the font color for the month/year title.

When the ShowTitle property is set to True (Yes), the calendar displays the month and year above the calendar grid. If the ShowDateSelectors property is set to False (No), the month/year title is centered above the grid, otherwise it is displayed to the left of the month and year combo box selectors.


ShowVerticalGrid Property

You can use the ShowVerticalGrid property to determine whether or not to display the vertical gridlines in a flat Calendar Control.

Syntax

controlname[.Object].ShowVerticalGrid = [ show]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The ShowVerticalGrid property uses the following setting.

Setting	Property Sheet	Visual Basic
show	Check or uncheck the Vertical Gridlines box in the Show option group in the General tab of the Calendar Control custom property sheet, or select Yes or No from the drop-down list for this argument in the Microsoft Access property sheet.	A boolean value (True or False) representing whether or not to display the vertical gridlines for a flat Calendar Control.
You can set this property in the Calendar Control custom property sheet, in the Microsoft Access property sheet, in a macro, or in Visual Basic.

Remarks

The ShowVerticalGrid property has no effect unless the GridCellEffect property is set to "Flat".


TitleFont Property

You can use the TitleFont property to specify the font used when displaying the month/year title above the calendar grid.

Syntax

controlname[.Object].TitleFont [ = name ]

controlname[.Object].TitleFont.Name [ = name ]

controlname[.Object].TitleFont.Size [ = size ]

controlname[.Object].TitleFont.Bold [ = bold ]

controlname[.Object].TitleFont.Italic [ = italic ]

controlname[.Object].TitleFont.Underline [ = underline ]

controlname[.Object].TitleFont.Strikethrough [ = strikethrough ]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The TitleFont property uses the following settings.

Setting	Property Sheet	Visual Basic
name	Select a font from the Font box list in the Fonts tab of the Calendar Control custom property sheet.	A string expression representing the font name, such as "MS Sans Serif" or "Times New Roman"
size	Enter or select a font size in the Size box in the Fonts tab of the Calendar Control custom property sheet.	A numeric expression representing the font size, such as 8, 10, or 12.
bold	Select Regular, Bold, or Bold Italic in the Font Style box in the Fonts tab of the Calendar Control custom property sheet.	A boolean expression (True or False) representing whether or not to use a boldface font.
italic	Select Regular, Italic, or Bold Italic in the Font Style box in the Fonts tab of the Calendar Control custom property sheet.	A boolean expression (True or False) representing whether or not to use an italic (slanted) font.
underline	Check or uncheck the Underline box in the Effects option group in the Fonts tab of the Calendar Control custom property sheet.	A boolean expression (True or False) representing whether or not to underline the font.
strikethrough	Check or uncheck the Strikeout box in the Effects option group in the Fonts tab of the Calendar Control custom property sheet.	A boolean expression (True or False) representing whether or not to use a strikethrough font, drawing a line through the center of the text.
You can set this property in the Calendar Control custom property sheet, in a macro, or in Visual Basic. You can't set it in the Microsoft Access property sheet.

Remarks

The month/year title is displayed at the top of the Calendar Control, above the days of the week, and next to the month combo box. You can use the ShowTitle property to determine whether the month/year title is displayed, the ShowDateSelectors property to determine whether the month and year combo boxes are displayed, and the ShowDays property to determine whether the days of the week are displayed. You can use the TitleFontColor property to set the font color for the month/year title.

The default property for a font is its name, so setting the TitleFont property in a macro or Visual Basic is identical to setting the TitleFont.Name property.


TitleFontColor Property

You can use the TitleFontColor property to specify the color used when displaying the days of the week in the Calendar Control.

Syntax

controlname[.Object].TitleFontColor [ = color ]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The TitleFontColor property uses the following setting.

Setting	Property Sheet	Visual Basic
color	Select a color in the Colors tab of the Calendar Control custom property sheet, or enter a number that represents an RGB color in the Microsoft Access property sheet.	A Long Integer data type that represents an RGB color.
You can set this property in the Calendar Control custom property sheet, in the Microsoft Access property sheet, in a macro, or in Visual Basic.

Remarks

The month/year title is displayed at the top of the Calendar Control, above the days of the week, and next to the month combo box. You can use the ShowTitle property to determine whether the month/year title is displayed, the ShowDateSelectors property to determine whether the month and year combo boxes are displayed, and the ShowDays property to determine whether the days of the week are displayed. You can use the TitleFont property to set the font for the month/year title.

The valid range for a normal RGB color is 0 to 16,777,215 (&HFFFFFF). The high byte of a number in this range equals 0; the lower three bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (&HFF).

If the high byte is not 0 (the number is negative), Microsoft Access uses the system colors, as defined in the user's Windows Control Panel. Microsoft Windows provides a set of negative numbers that correspond to various parts of an application's window (for example, the window frame, or the title bar text). You can set the TitleFontColor property to one of these numbers, and Microsoft Access will use the color you've selected for this part of the window. For more information, see Set color properties to Microsoft Windows system colors. The Colors tab in the Calendar Control custom property sheet has a System Color box where you can select a system color for this property.


Value Property (Calendar Control)

You can use the Value property to set or retrieve the current date in the Calendar Control.

Syntax

controlname[.Object].Value [ = date ]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The Value property uses the following setting.

Setting	Property Sheet	Visual Basic
date	Set the value in the calendar by moving the focus to a particular date; enter a date in the Value box in the General tab of the Calendar Control custom property sheet; or enter a date in the Microsoft Access property sheet.	A date or Null.
You can set this property in the Calendar Control custom property sheet, in the Microsoft Access property sheet, in a macro, or in Visual Basic.

Remarks

Valid Calendar Control dates are from 1/1/1900 to 12/31/2100. You can also set the Value property to Null, causing no date to be highlighted.

The Value property is also changed when you use the arrow keys, the mouse, or the date selector combo boxes to change the date.

You can bind the Calendar Control to a field in the underlying table for the form containing the Calendar Control using the ControlSource property. If you do, setting the Value property sets this field in the table, and the Calendar Control will display the value of this field for each record on the form. The underlying field in the table must be a Date/Time field.


ValueIsNull Property
ValueIsNull Property (Calendar Control)

You can use the ValueIsNull property to determine whether or not to highlight the current date on the Calendar Control.

Syntax

controlname[.Object].Value [ = isnull ]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The ValueIsNull property uses the following setting:

Setting	Property Sheet	Visual Basic
isnull	Select Yes or No from the drop-down list for this argument in the Microsoft Access property sheet.	A boolean value (False or True) representing whether or not to highlight the current date on the Calendar Control.
You can set this property in the Microsoft Access property sheet, in a macro, or in Visual Basic.

Remarks

When you set the ValueIsNull property to True, the current date is not lost. When you set the ValueIsNull property back to False, the current date is highlighted again.

Setting the Value property directly or using the arrow keys, the mouse, or the date selector combo boxes to select a date automatically sets the ValueIsNull property to False (No).


Year Property

You can use the Year property to set the current year to display in the Calendar Control.

Syntax

controlname[.Object].Year = [ year ]

controlname is the name of the Calendar Control object, for example, OLEControl0.

Setting

The Year property uses the following setting.

Setting	Property Sheet	Visual Basic
year	Set the property to the year you want in the Microsoft Access property sheet.	An Integer value between 1900 and 2100.
You can set this property in the Microsoft Access property sheet, in a macro, or in Visual Basic.

Remarks

The Calendar Control displays years from 1900 to 2100.


AboutBox Method

You can use the AboutBox method to display an informational dialog box about the Calendar Control, including its version and copyright information.

Syntax

controlname[.Object].AboutBox

The AboutBox method uses the following argument.

Argument	Description

controlname	The name of the Calendar Control object, for example, OLEControl0.

Remarks

You can also view the About box by clicking the About property in the Microsoft Access property sheet, then clicking the Build button to the right of the property box.


NextDay Method

You can use the NextDay method to increment the day, reset the month (if the current day is the last day of the month), and repaint the calendar in a single operation.

Syntax

controlname[.Object].NextDay

The NextDay method uses the following argument.

Argument	Description

controlname	The name of the Calendar Control object, for example, OLEControl0.

Remarks

Pressing the RIGHT ARROW key on the keyboard is identical to executing this method.


NextDay Method Example

The example displays the calendar for the subsequent day when the user clicks the button identified as cmdNextDay. You don't have to specify a form name when you refer to the Calendar Control on the active form. In this example, the Calendar Control is named fraCalendar.

Private Sub cmdNextDay_Click ()

fraCalendar.Object.NextDay

End Sub


NextMonth Method

You can use the NextMonth method to increment the month, reset the year (if the current month is December), and repaint the calendar in a single operation.

Syntax

controlname[.Object].NextMonth

The NextMonth method uses the following argument.

Argument	Description

controlname	The name of the Calendar Control object, for example, OLEControl0.

Remarks

Pressing the RIGHT ARROW key while holding down the CTRL key on the keyboard is identical to executing this method.


NextMonth Method Example

The example displays the calendar for the subsequent month when the user clicks the button identified as cmdNextMonth. You don't have to specify a form name when you refer to the Calendar Control on the active form. In this example, the Calendar Control is named fraCalendar.

Private Sub cmdNextMonth_Click ()

fraCalendar.Object.NextMonth

End Sub


NextWeek Method

You can use the NextWeek method to increment the week, reset the month (if the current day is in the last week of the current month), and repaint the calendar in a single operation.

Syntax

controlname[.Object].NextWeek

The NextWeek method uses the following argument.

Argument	Description

controlname	The name of the Calendar Control object, for example, OLEControl0.

Remarks

Pressing the DOWN ARROW key on the keyboard is identical to executing this method.


NextWeek Method Example

The example displays the calendar for the subsequent week when the user clicks the button identified as cmdNextWeek. You don't have to specify a form name when you refer to the Calendar Control on the active form. In this example, the Calendar Control is named fraCalendar.

Private Sub cmdNextWeek_Click ()

fraCalendar.Object.NextWeek

End Sub


NextYear Method

You can use the NextYear method to increment the year and repaint the calendar in a single operation.

Syntax

controlname[.Object].NextYear

The PreviousMonth method uses the following argument.

Argument	Description

controlname	The name of the Calendar Control object, for example, OLEControl0.

Remarks

Pressing the DOWN ARROW key while holding down the CTRL key on the keyboard is identical to executing this method.


NextYear Method Example

The example displays the calendar for the subsequent year when the user clicks the button identified as cmdNextYear. You don't have to specify a form name when you refer to the Calendar Control on the active form. In this example, the Calendar Control is named fraCalendar.

Private Sub cmdNextYear_Click ()

fraCalendar.Object.NextYear

End Sub


PreviousDay Method

You can use the PreviousDay method to decrement the day, reset the month (if the current day is the first day of the month), and repaint the calendar in a single operation.

Syntax

controlname[.Object].PreviousDay

The PreviousDay method uses the following argument.

Argument	Description

controlname	The name of the Calendar Control object, for example, OLEControl0.

Remarks

Pressing the LEFT ARROW key on the keyboard is identical to executing this method.


PreviousDay Method Example

The example displays the calendar for the previous day when the user clicks the button identified as cmdPreviousDay. You don't have to specify a form name when you refer to the Calendar Control on the active form. In this example, the Calendar Control is named fraCalendar.

Private Sub cmdPreviousDay_Click ()

fraCalendar.Object.PreviousDay

End Sub


PreviousMonth Method

You can use the PreviousMonth method to decrement the month, reset the year (if the current month is January), and repaint the calendar in a single operation.

Syntax

controlname[.Object].PreviousMonth

The PreviousMonth method uses the following argument.

Argument	Description

controlname	The name of the Calendar Control object, for example, OLEControl0.

Remarks

Pressing the LEFT ARROW key while holding down the CTRL key on the keyboard is identical to executing this method.


PreviousMonth Method Example

The example displays the calendar for the previous month when the user clicks the button identified as cmdPreviousMonth. You don't have to specify a form name when you refer to the Calendar Control on the active form. In this example, the Calendar Control is named fraCalendar.

Private Sub cmdPreviousMonth_Click ()

fraCalendar.Object.PreviousMonth

End Sub


PreviousWeek Method

You can use the PreviousWeek method to decrement the week, reset the month (if the current day is in the first week of the current month), and repaint the calendar in a single operation.

Syntax

controlname[.Object].PreviousWeek

The PreviousWeek method uses the following argument.

Argument	Description

controlname	The name of the Calendar Control object, for example, OLEControl0.

Remarks

Pressing the UP ARROW key on the keyboard is identical to executing this method.


PreviousWeek Method Example

The example displays the calendar for the previous week when the user clicks the button identified as cmdPreviousWeek. You don't have to specify a form name when you refer to the Calendar Control on the active form. In this example, the Calendar Control is named fraCalendar.

Private Sub cmdPreviousWeek_Click ()

fraCalendar.Object.PreviousWeek

End Sub


PreviousYear Method

You can use the PreviousYear method to decrement the year and repaint the calendar in a single operation.

Syntax

controlname[.Object].PreviousYear

The PreviousYear method uses the following argument.

Argument	Description

controlname	The name of the Calendar Control object, for example, OLEControl0.

Remarks

Pressing the UP ARROW key while holding down the CTRL key on the keyboard is identical to executing this method.


PreviousYear Method Example

The example displays the calendar for the previous year when the user clicks the button identified as cmdPreviousYear. You don't have to specify a form name when you refer to the Calendar Control on the active form. In this example, the Calendar Control is named fraCalendar.

 Private Sub cmdPreviousYear_Click ()

fraCalendar.Object.PreviousYear

End Sub


Refresh Method (Calendar Control)

You can use the Refresh method to repaint the Calendar Control.

Syntax

controlname[.Object].Refresh

The Refresh method uses the following argument.

Argument	Description

controlname	The name of the Calendar Control object, for example, OLEControl0.


Refresh Method, FirstDay Property Example

This example uses the AfterUpdate event for a text box named txtFirstDay that accepts a day number as the first day to display in the calendar. The day is passed to the Case statement that sets the Calendar Control's FirstDay property. The value passed to this property corresponds to the day that the user selects (1 = Sunday, 2 = Monday, ..., 7 = Saturday).

You don't have to specify a form name when you refer to the Calendar Control on the active form. In this example, the Calendar Control is named fraCalendar.

Private Sub txtFirstDay_AfterUpdate ()

  'Set the FirstDay property based on the text box named txtFirstDay.

  Select Case txtFirstDay

    Case 1

      fraCalendar.Object.FirstDay = 1

    Case 2

      fraCalendar.Object.FirstDay = 2

    Case 3

      fraCalendar.Object.FirstDay = 3

    Case 4

      fraCalendar.Object.FirstDay = 4

    Case 5

      fraCalendar.Object.FirstDay = 5

    Case 6

      fraCalendar.Object.FirstDay = 6

    Case 7

      fraCalendar.Object.FirstDay = 7

  End Select

  'Repaint the Calendar Control using the Refresh method.

  fraCalendar.Object.Refresh

End Sub


Today Method

You can use the Today method to set the calendar’s date to today’s date and repaint the calendar in a single operation.

Syntax

controlname[.Object].Today

The Today method uses the following argument.

Argument	Description

controlname	The name of the Calendar Control object, for example, OLEControl0.

Remarks

Pressing CTRL+T (the T key while holding down the CTRL key) on the keyboard is identical to running this method.


AfterUpdate Event (Calendar Control)

The AfterUpdate event occurs after the user moves to a new date in the Calendar Control and the new date is highlighted.

Syntax

Sub controlname_AfterUpdate( )

The AfterUpdate event procedure uses the following argument.

Argument	Description

controlname	The name of the Calendar Control object, for example, OLEControl0.

Remarks

This event occurs whenever the user moves to a new date in the Calendar Control, using the keyboard keys or the mouse.


BeforeUpdate Event (Calendar Control)

The BeforeUpdate event occurs after the user moves to a new date in the Calendar Control but before the new date is highlighted.

Syntax

Sub controlname_BeforeUpdate (Cancel as Integer)

The BeforeUpdate event procedure uses the following arguments.

Argument	Description

controlname	The name of the Calendar Control object, for example, OLEControl0.

Cancel	Specifies whether the calendar should be updated with the user's requested date.

Remarks

If the user's input is limited to a range of dates and their selection falls outside of that range, the BeforeUpdate event procedure can be used to cancel the calendar update. By setting the cancel argument to True within the BeforeUpdate event procedure, the application informs the Calendar Control that it should not update the associated calendar.

This event occurs whenever the user moves to a new date in the Calendar Control, using the keyboard keys or the mouse.


Click Event (Calendar Control)

The Click event occurs when the user clicks on a date in the Calendar Control.

Syntax

Sub controlname_Click()

The Click event procedure uses the following argument.

Argument	Description

controlname	The name of the Calendar Control object, for example, OLEControl0.

Remarks

Once the user has clicked on a date, the application can retrieve that date with the Value property.


DblClick Event (Calendar Control)

The DblClick event occurs when the user double-clicks on a date in the Calendar Control.

Syntax

Sub controlname_DblClick()

The DblClick event procedure uses the following argument.

Argument	Description

controlname	The name of the Calendar Control object, for example, OLEControl0.

Remarks

Once the user has double-clicked on a date, the application can retrieve that date with the Value property.


KeyDown, KeyUp Events (Calendar Control)

The KeyDown and KeyUp events occur when the user presses or releases a key while the Calendar Control has the focus.

Syntax

Sub controlname_KeyDown (KeyCode, Shift)

Sub controlname_KeyUp (KeyCode, Shift)

The KeyDown and KeyUp event procedures use the following arguments.

Argument	Description

controlname	The name of the Calendar Control object, for example, OLEControl0.

KeyCode	A key code such as vbKeyF1 (for the F1 key) or vbKeyHome (for the HOME key).

Shift	A value specifying the state of the SHIFT, CTRL, and ALT keys. The least-significant bit (bit 0) corresponds to the SHIFT key, the next bit (bit 1) corresponds to the CTRL key, and the next bit (bit 2) corresponds to the ALT key.


KeyPress Event (Calendar Control)

The KeyPress event occurs when the user presses and releases an ANSI key while the Calendar Control has the focus.

Syntax

Sub controlname_KeyPress (KeyAscii)

The KeyPress event procedure uses the following arguments.

Argument	Description

controlname	The name of the Calendar Control object, for example, OLEControl0.

KeyAscii	A numeric ANSI key code. This argument is passed by reference.


 NewMonth Event

The NewMonth event occurs whenever the calendar changes to a different month.

Syntax

Sub controlname_NewMonth

The NewMonth event procedure uses the following arguments.

Argument	Description

controlname	The name of the Calendar Control object, for example, OLEControl0.


NewYear Event

The NewYear event occurs whenever the calendar changes to a different year.

Syntax

Sub controlname_NewYear

The NewYear event procedure uses the following arguments.

Argument	Description

controlname	The name of the Calendar Control object, for example, OLEControl0.