Solved

DTPicker - ability to type the whole date

Posted on 2014-09-16
7
90 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Modifying Conditional Format from VBA code 3 84
Set email body to html using vbscript 6 93
VB6 - Scroll Mouse wheel on Picturebox 13 119
2 Global Vars, 1 List Box 4 31
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

732 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