Need help inputting a Calendar for DOB in form.

ismith

Registered User.
Local time
Today, 07:08
Joined
Dec 14, 2011
Messages
30
Hello,

Ive got a Date of Birth txtbox which if the user clicks it, it should pop up with a calendar that the user can then choose a date for the DOB.

Now ive seen a few people say that you change the 'Show date Picker' to "For Dates".

Now ive done this and the pop up calendar still dont come up. My txtBox is an Unbound box.

Ive also checked the ActiveX Controls but i cant find the Date/Calendar section to add one.

Can anyone help me on how to do it?

Thanks..
 
Make sure that the text box is formatted to a date format.

Also make sure that you do not have an Input Mask defined for the text box.
 
But is your textbox bound to a Date/Time data type field?
 
With all due respect, the text box does not have to be bound to a Date/Time field for the calendar option to work. The text box must be formatted as Date/time and there must not be an Input Mask for it.
 
Ive got a Date of Birth txtbox which if the user clicks it, it should pop up with a calendar that the user can then choose a date for the DOB.
Mr. B,

I'm aware that the textbox doesn't need to be bound to a field for the Date Picker to become visible, but being a Date of Birth textbox you would expect it to be bound to a field.
 
Ive got it working now so when I click it the date picker comes up.
At the moment, it shows the current month in the current year.

So if someone was born in for example 1980, it wouldnt be convienient for them to keep clicking back till they get to 1980's.

Is there anyway i can get another calendar which you can input the year and it then goes to that year?

Thanks..
 
The Value of the Date textbox needs to be set for the built-in Date Picker to pick up the last entered date, and this is set when the textbox loses focuses.

Here's a workaround. Put the following in the Change event of the Date textbox:
Code:
With Me.[COLOR=Red]DateTextbox[/COLOR]
    If IsDate(.Text) Then
        Dim prevStart As Integer
        
        prevStart = .SelStart
        .Value = .Text
        .SelStart = prevStart
    End If
End With
Substitute DateTextbox with the actual name of your textbox control.
 
The Value of the Date textbox needs to be set for the built-in Date Picker to pick up the last entered date, and this is set when the textbox loses focuses.

Here's a workaround. Put the following in the Change event of the Date textbox:
Code:
With Me.[COLOR=Red]DateTextbox[/COLOR]
    If IsDate(.Text) Then
        Dim prevStart As Integer
        
        prevStart = .SelStart
        .Value = .Text
        .SelStart = prevStart
    End If
End With
Substitute DateTextbox with the actual name of your textbox control.

So what will this do?

Because ive got a Form which i can add customers.
So the DOB txtbox is in that form.

The code uve given above wt will it do?

Thanks for the help..
 
Atm ive got this code

Code:
    Dim selectedDate, date16  As Date
    
    'get the date 16 years ago
    date16 = DateAdd("yyyy", -16, Now)
    'get the date selected from the calendar
    selectedDate = txtDOB.Value
'    MsgBox dte16
'    MsgBox datSelected
'   date selected plus 16 years must be less than the date now
    If selectedDate <= date16 Then
        txtDOB.Value = selectedDate
        txtContactNo.SetFocus
    Else
        MsgBox "Customer must be 16 or above", vbCritical, "Age: "
        txtDOB.Value = ""
        txtDOB.SetFocus
    End If

That gives a msg when the date is less than 16 yrs.

But for the calendar Its nt convienient for the user to keep pressing back on the calendar to get to the year they were born in..
 
The code uve given above wt will it do?
It's the answer to your question -->
So if someone was born in for example 1980, it wouldnt be convienient for them to keep clicking back till they get to 1980's.

Is there anyway i can get another calendar which you can input the year and it then goes to that year?
If the record already exists and you click on the built-in date picker, it will go to that date. But if you've just typed a date into the textbox and click on the buit-in date picker, it will not move to the date you've just typed. The code I gave makes it go to that date.
 

Users who are viewing this thread

Back
Top Bottom