Solved

DTPicker - ability to type the whole date

Posted on 2014-09-16
7
83 Views
Last Modified: 2014-09-17
DTPicker is great but can slow a user down in the manner the date is entered.  Is there a way to allow the user to "completely" type the whole date as when they do with a textbox?  If not, are there other options?
0
Comment
Question by:al4629740
  • 4
  • 2
7 Comments
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
I don't understand the question since by default DTPicker shows the current date and if the dropdown is selected you get a calendar from which the user can select a date with one or two clicks.
0
 

Author Comment

by:al4629740
Comment Utility
The users entering birthdates

So the years is very greatly.
0
 
LVL 45

Accepted Solution

by:
Martin Liss earned 500 total points
Comment Utility
Then how about an InputBox instead of DTPicker.

Dim dt As Date

On Error Resume Next
dt = InputBox("Please enter the birthdate ", "Enter Birthdate", Format(Now(), "YYYY-MM-DD"))

If Not IsDate(dt) Or _
   Right$(dt, 4) < "1930" Or Right(dt, 4) > "2100" Or _
   Left$(dt, 2) < "01" Or Left$(dt, 2) > "12" Or _
   Mid$(dt, 4, 2) < "01" Or Mid$(dt, 4, 2) > "31" Then
    MsgBox "Invalid Date, please try again"
End If

Open in new window

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:al4629740
Comment Utility
I was hoping not to, but that may be my only option....


That is an interesting approach.  I used to do the following for a textbox DOB

If Not Text5.Text = "" Then

    If IsDate(Text5) = False Then
    MsgBox "Enter a Valid Date in the Correct Format", vbOKOnly, "Date"
    Exit Sub
    End If
    
Text5 = Format(Text5, "mm/dd/yyyy")

End If

Open in new window


What is the difference between mine and yours?
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
The difference is that I believe with your code if you put in a date like 2014-09-33 it will say it's valid.
0
 
LVL 12

Expert Comment

by:jkaios
Comment Utility
Try this:

Private Sub Form_Load()
   DTPicker.Format = dtpCustom
   DTPicker.CustomFormat = "MM/dd/yyyy"
   DTPicker.Value = Date
End Sub

Open in new window

0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now