Solved

DTPicker - ability to type the whole date

Posted on 2014-09-16
7
92 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 47

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 47

Accepted Solution

by:
Martin Liss earned 500 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 47

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 47

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 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