• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Date Picker Values

Sojourner26

New Member
Help is requested for setting parameters for acceptable selected dates using the DatePicker. As project is for a hotel booking system, a check-in date and check-out date are selected during booking. What shall be the VBA macro such that the check-in date is today's date and greater? It cannot be a date in the past. The check-out date is one day greater and more for the check-in date.

Thank you for the help.
 
In VBA, Date function gives today's date, much like TODAY() function in worksheet.

Just use that to check. But without sample workbook and/or code. Hard to say exactly how you'd want to use it.
 
Hmm, I don't see date picker in the project. There is subs that allude to it (DTPicker1_CallybackKeyDown) and it's used in part of code. But object itself does not exist in the sample.

At any rate, what I normally do is to have label and command button.
Command button to launch date picker module (you can write your own code, or just use the one written by schmolio007) and label to hold the value.

Link to date picker thread below.
https://chandoo.org/forum/threads/fully-customizable-vba-date-picker.19508/

Or the author's site.
https://trevoreyre.com/portfolio/excel-datepicker/

As site explains, store into date variable CalendarForm.GetDate result.
So using command button... using Check-in date as example.
Code:
Private Sub DatePickerCmd_Click()
Dim myDate As Date
myDate = CalendarForm.GetDate

If myDate < Date Then
    MsgBox "Please pick today's date or later for Checkin"
Else
    'Some code goes here
End If
End Sub



http://trevoreyre.com/portfolio/excel-datepicker/
 
Hi,

The Date Picker I installed can be viewed in action in this YouTube video:


I still haven't solved on my own the VBA code to reject date selected that is a past date.

Again many thanks for all the help.
 
When the Excel VBA Picker file in the website is downloaded, the Zip program detects that a password is needed..
 

Attachments

  • Calendar Frm.jpg
    Calendar Frm.jpg
    50.5 KB · Views: 8
Back
Top