?
Solved

DTPicker - ability to type the whole date

Posted on 2014-09-16
7
Medium Priority
?
95 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40326853
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
ID: 40326896
The users entering birthdates

So the years is very greatly.
0
 
LVL 49

Accepted Solution

by:
Martin Liss earned 2000 total points
ID: 40326925
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:al4629740
ID: 40327000
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 49

Expert Comment

by:Martin Liss
ID: 40327008
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
ID: 40327092
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 49

Expert Comment

by:Martin Liss
ID: 40329442
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Suggested Courses
Course of the Month8 days, 14 hours left to enroll

765 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