A better date picker (1 Viewer)

Status
Not open for further replies.

isladogs

CID VIP
Local time
Today, 05:53
Joined
Jan 14, 2017
Messages
16,426
Some months ago I uploaded a replacement date picker (see DatePicker.accdb attached) that has no Active X controls and can also be used in 64-bit Access.

It was originally posted in response to a question about Stephen Lebans' calendar in this thread

https://www.access-programmers.co.uk/forums/showthread.php?p=1533910#post1533910

Having just spent a long time searching for the thread, I'm posting it here so its easier to find in the future! ;)

The original version by Brendan Kidwell is open source from 2003 and can be found here:
http://www.glump.net/content/accessdatepicker/

However, I've made extensive changes to the appearance of the calendar form



If all you want is a visual calendar, it will certainly do that
However, its main purpose is to input a date in a form textbox
All you need for that is one line of code in the textbox click event:

Code:
Private Sub txtDate_Click()
    InputDateField txtDate, "Select a date to use this on your form"
End Sub

The string "Select a date to use this on your form" is used for info on the form and can be adapted to suit

To use, copy frmDatePicker & modDatePicker to your own database
Ignore frmMain - its only needed for the example db
 

Attachments

  • DatePicker.zip
    90.9 KB · Views: 2,545
  • DatePicker.PNG
    DatePicker.PNG
    24.2 KB · Views: 8,918
Last edited:

Scribtor

Registered User.
Local time
Today, 06:53
Joined
Sep 27, 2018
Messages
16
Million thanks! Should be a sticky so as to be easier to reach :D
 

isladogs

CID VIP
Local time
Today, 05:53
Joined
Jan 14, 2017
Messages
16,426
Glad you like it. If there are too many stickies, none of them stand out.
 

soap

Registered User.
Local time
Yesterday, 21:53
Joined
Nov 4, 2018
Messages
25
Thank you very helpful
 

JoeNoEskimo

New member
Local time
Yesterday, 23:53
Joined
Mar 29, 2019
Messages
3
Very nice tool. I have added it to my pet project. I did however make one little addition. At some places in the database I'm working on I want the date picker to return date and time. So I made this change:

' Use this method to prompt for and set a new date on a textbox
Public Sub InputDateField(x As TextBox, AddTime As Boolean, Optional Prompt As String = "Select Date")

mPrompt = Prompt
mInitDate = x.Value

RunDialog

If IsDate(mReturnValue) Then
If AddTime = True Then
x.Value = mReturnValue & " " & Time()
Else
x.Value = mReturnValue
End If
End If

End Sub

Call it:
InputDateField DonationDate, False, "Date Picker"
InputDateField DistributionDateTime, True, "Date Picker"

I hope this little addition helps someone else,
Joe
 

rxm01l

Registered User.
Local time
Yesterday, 21:53
Joined
Mar 5, 2013
Messages
32
I would like to utilize this Calendar on my form contained. Start_Date and End_Date.. How would I code this so that your Calendar popup so that I can select Start_Date from Calendar and End_Date from this Calendar? Please advise.. Thank You..
 

isladogs

CID VIP
Local time
Today, 05:53
Joined
Jan 14, 2017
Messages
16,426
Hi rxm
Just follow the instuctions in post #1, adding the InputDateField code to the click event of both date controls
 

rxm01l

Registered User.
Local time
Yesterday, 21:53
Joined
Mar 5, 2013
Messages
32
Thank You Isladogs, I got it to work right after I posted my question. Great learning tool..

If I want add a Fix Time after selecting Date. Example: 08/07/2019 07:00:00 AM or 08/07/2019 03:00:00 PM, how would I do that by using this Calendar? in my old Calendar I used:
Me.Start_DATE.Value = Me.Calendar.Value +TimeValue ("03:00:00 AM").. doesn't see to work on this calendar... Any recommendation would be appreciated.. Thank You so much..
 

isladogs

CID VIP
Local time
Today, 05:53
Joined
Jan 14, 2017
Messages
16,426
Hi rxm
Posting a question often leads almost immediately to the solution ;)
Regarding times, have you looked at the code suggested by JoeNoEskimo in post #6?
 

isladogs

CID VIP
Local time
Today, 05:53
Joined
Jan 14, 2017
Messages
16,426
Following suggestions at both Utter Access & by @KitaYama here at AWF, I have made a number of significant changes to the better date picker utility.

datepickerForm.png


The main changes in the latest version (1.4) are:
a) First day of week now automatically assigned according to Windows settings - no need for multiple versions
b) Date format automatically assigned according to Windows regional settings
For example: dd/mm/yyyy (UK); mm/dd/yyyy (USA); dd.mm.yyyy (Germany); d/m/yyyy (Greece); yyyy/mm/dd (Japan)
c) Day and month names are displayed using the regional language currently in use.
d) Out of month days added in dark grey (optional)
e) Days from following month only shown if in same week as last day of current month (also optional)
f) Selecting an out of month day assigns the correct month automatically.
Also works successfully for dates selected in previous year or following year
g) Clicking the Today button resets the calendar to the current month/year & highlights current date ready for selection to confirm

Here are some examples of different languages, start days & date formats:

Greek - Mon to Sun - d/m/yyyy format
DatePickerForm_Greek_Mon-Sun.png


Japanese - Sun to Sat - yyyy/mm/dd format
DatePickerForm_Japanese_Sun-Sat.png


German - Mon to Sun - dd.mm.yyyy format
DatePickerForm_German_Sun-Sat.png
 

Attachments

  • DatePicker_v1.4.zip
    71.6 KB · Views: 89
Status
Not open for further replies.

Users who are viewing this thread

Top Bottom