Solved

DTPicker - ability to type the whole date

Posted on 2014-09-16
7
84 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 46

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 46

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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 46

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 46

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel Spreadsheet - Send email if certain value is selected. 14 87
Controlling which port to download from 4 71
using web browser with BING 40 110
Help me. 3 46
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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

920 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

16 Experts available now in Live!

Get 1:1 Help Now