Home  |   French  |   About  |   Search  | mvps.org  

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

In Memoriam

Terms of Use


VB Petition

Forms: Date Picker without ActiveX

Author(s)
Brendan Kidwell
 (Q) I have a form with a date field or a block of code that needs to
input a date and I want to the user to have a calendar view to select
that date from. I don't want to use any ActiveX components.

(A) Use the Access Date Picker.

Download the attached database and import the form "DatePicker" and the
module "mdlDatePicker" into your project.


Make a CommandButton next to the form's TextBox containing the date and
add some code to its Click event like this:
 

'   ***** Code Start *****
Private Sub DateButton_Click()
InputDateField DateTextBox, "Some prompt"
End Sub ' ***** Code End *****
(You might want to use Access' built-in "Calendar" icon as the
CommandButton's picture, and leave the caption blank.)

If you have a block of code that needs to stop and ask for a date as it
runs, do something like this:

'   ***** Code Start *****                
Private Sub SomeAction()
Dim d As Variant
' Initialize whatever needs initializing
d = InputDate("Some prompt")
' d is now a date (IsDate(d) = True) or Null, if the user
' cancelled.
' Do something with useful with d.
End Sub ' ***** Code End *****

InputDateField() will not affect the specified TextBox if the user
clicks the Cancel button on the DatePicker form. Likewise you must be
aware that InputDate() will return a Null value instead of a date if the
user clicks Cancel and your code must handle it appropriately.

Other features include specifying the initial date that the DatePicker
form presents to the user. See the readme file for more details.

Download DatePicker

 


1998-2010, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer