Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Validating A Date Picker In Vb6.0

Hallo guys,
I'm still knew in vb and would like to know how to validate a date picker.
For example I have a date picker in one of my forms and would like it not to allow the user to choose a date before last year. A typical example I'd not want the user to choose 1890 as the year of birth. Thanks in advance

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Validating Server's Date Against A Date In An MS Access Database
I'm trying to redirect a user based on what date the field "expires" in my MS Access 2K DB has - This section is where I want to redirect to a page if the expires date in my database = today.

I'm selecting the table above ( rsUser.Source = "SELECT user_username, user_password, expires" ) but I don't think that the Sub is written right.

    Sub currentDate
    currentDate = Date
    If expires = Date Then
    redirectLoginSuccess = "expiretoday.asp"
    End If
    End Sub

I'm new to VB; the ASP page I'm calling this through just skips this routine - which means I didn't do it right. Any suggestions?

Date Picker Control Doesn't Show Current Date In Field
How do I set the display date in the Date Picker control field ? MSDN says that it should return the current date by default, but it only shows the current date highlighted in the drop down calendar.

The control shows the date when the control was created and added to the form.

How do I set the date at form load ?

dtpicker1.value = ? ' how do I call current date ?

Date Time Picker >> Fuction To Calculate A Specific Date
I have two Date Time Picker controls.

What needs to happen is when user selects a date in DTPicker1 then a date 7 months later, on the following tuesday is displayed in DTPicker2.

Any help with this would be great.

Date Time Picker Control: How Do Set The Displayed Date To Null?
I have a front end database form with date fields using the MS dtp control. The fields are unbound, but populated using a data class. The problem is that on many occasions the date field is Null, ie no data available. On display the dtp control always defaults to a set date, usually today (this is a property function of the control). What I can't seem to do is to display no date, or to delete the date displayed. Any thoughts would be very gratefully recieved. API perhaps?

I'm trying very hard not to have to write an Active-X control based on the dtp (mainly because of multilingual support and different localisation issues regarding dd/mm/yyyy (used by 90% of the world's population, and mm/dd/yyy - used by the remaining 10% in the US - sorry just had to get that jibe in for those of us who despair at having to go in to custom formatting in Excel simply to get dd/mm/yy )

Many thanks

Updating Date Field With Null Value (date Picker)

I am using VB and access. For date I am nsing date Picker. How can I update a date with null value?

I am using the code update the date field:

DateColumn=#" & Format(DTP1, "mm/dd/yyyy") & "#

When I try to udate the field with null value I receive error: syntex error in date in query expression '##'.
Please advice me how to update with null values.


Diplay No Date In The Date Time Picker
anyone know how to display no date or have the date time picker come up with no date in it when starting up a program. My program comes up with fields displayed but blank and disabled. I would like to use the time picker and have the field come up disabled and blank.

Any ideas??????

Date Validating
is there a way i can check a date in a text box to see if it is a valid date, ie 45:99:-1 would be an invalid date

Validating A Date
What sort of thing would I need to put in the validate event of a textbox to make sure that only a date between two certain dates could be added? Thanks.

Validating Date
I have a textbox for entering date in the form. i want to format it so that if user enters the date without the slashes or enters in incorrect format that it gets correct automatically. can somoen pls help me with this.

for example:

if someone enters 812005 i want it to be converted to "8/1/2005".
or if someone make a typo like 81/2005 i want to be corrected or display give a message to the user.

Validating Date

Here's a strange behaviour of the IsDate function that i am encountering in my VB Application.

This function is used in my code to validate date on lost focus. This function all this while i assumed was working fine. While testing i found a strange behaviour... here are the steps:

1. In my regional settings Location is - English (United Kingdom)
2. Short Date: dd/MM/yyyy, Long Date: dd MMMM yyyy
3. In Vb, the function is as following:
Private Sub txtApptDate_LostFocus()
    If Trim(txtApptDate.Text) <> "" Then
        If IsDate(txtApptDate.Text) = False Then
            MsgBox "Invalid Date!!", vbInformation, App.Title
            txtApptDate.SelStart = 0
            txtApptDate.SelLength = Len(Trim(txtApptDate.Text))
        End If
    End If
End Sub

4. In the front end enter the following dates:
    * 09/12/2004 (Is valid. Passes through)    
    * 09/13/2004 (Is Invalid. but, still Passes through)    
    * 12/13/2004 (Is Invalid. but, still Passes through)    
    * 13/13/2004 (Is Invalid. Displays Invalid Date message)    
    * 13/12/2004 (Is valid. Passes through)    
    * 13/10/2004 (Is valid. Passes through)    

In the above sample dates you will notice that some dates are invalid according to the dd/mm/yyyy format but they still pass through as valid dates. Why is this happening? at some instance the isdate passes through mm/DD/yyyy and in some instances it passes dd/MM/yyyy?

This is rather strange and i have never noticed this before in my development years in Vb...

Has anyone encountered the same? knows the resolution for it?


Edited by - simmani on 9/7/2004 6:50:41 AM

Validating Date
I am needing to validate that numbers entered into a text box are a valid date. Example 12122000 (12/12/2000), would be valid, but not 13122000 (13/12/2000). I tried using a DOS program's routine, but it won't work. "Ending" is the variable holding the date. I get the invalid Month MsgBox every run. If this can be fixed, please help. Otherwise, suggestions are greatly appreciated!

private Sub ValiDate()
If Val(mid$(Ending, 1, 2)) &lt; 1 Or Val(mid$(Ending, 1, 2)) &gt; 12 then
MsgBox "Invalid Month, Please enter again."
Exit Sub
End If

If Val(mid$(Ending, 3, 2)) &lt; 1 Or Val(mid$(Ending, 3, 2)) &gt; 31 then
MsgBox "Invalid Day, Please enter again."
Exit Sub
End If

If Val(mid$(Ending, 5, 2)) &lt; Val(mid$(date, 9, 2)) - 2 Or Val(mid$(Ending, 5, 2)) &gt; Val(mid$(date, 9, 2)) + 2 then
MsgBox "Invalid Year, Please enter again."
Exit Sub
End If
End Sub

Thank you,


Date Difference Using Date Picker
What is the secrect to finding the difference in date using the Date picker? Here is my inaccurate code:

Dim DaysRented as Long/Date/?
DaysRented = DateDiff("d", dtpEnd.value, dtpStart.value)

DaysRented value continues to be -1 if a long, integer and a strange date if declared a date. What's the secret to this?

Validating / Calculating Date

I'm having the following little Excel problem.

My worksheet has two columns, all celss defined as "Date".

Column A has dates on which a sales representative visits a certain company.

Column B has dates on which a letter has been sent to this company.

Now I want to make sure that all dates are entered corectly.

For example :
If the date value in column A is "higher" then the value in column B a message box should appear, telling the user that a wrong entry has been made.

Is there a simple way to do this using (for example) "Validating" in (Excel) VBA ?

Any help would be most welcome.

Frits Jager

VB6 - Validating Date Fields
Dev Environment: VB6 Code on MS Access2000 DB on win2K
I have two Date fields on my MS Access Form ie Date A and Date B.At any given time ,Date B must be greater than Date A.Date A is entered first then Date B follows.These dates are entered using a Calendar button with a command to set the date.I have tried to use Validation rule field property on table and form levels but didnt work out.Is there anyway else around???
Note that Calendar has been developed as an MS Access form with a command to set the date.Please help! Urgent!!

Validating A Future Date
hey people, how's u all!

ok i would appreciate it very much if any of you cud help me with my program......well basically ive made a program where you can enter a date in the STARTDATE box and entering a number in the DAYSTOADD box....and this basically calculates the new date....but i need some kind of validation check that would check whther the STARTDATE is a future date...and if this is the case then it wud pop up a msgbox...

so.....!!!can any1 help?!

Validating Date &amp; Time
I'm a beginning developer & I trying to validate DATE & TIME Strings or values. I'm writting a small Alarm Clock program(laugh if you wish) and I'm trying to make a message box appear when lblDisplay.text = specific date & specific time. I know this is probably simply can anyone help.


Need Help Validating The Date PLSSSSSS!!!
I want to make a validation routine that will check if the date you have entered is valid or not, this is my routine

Public Sub currentdatecheck(ByVal txtcurrentdate As Variant, validcurrentdate As Boolean, ByRef currentdateerrmsg As String)
Dim currentdate As Date

If txtcurrentdate = "" Then
currentdateerrmsg = "You must enter a date (Date format = DD/MM/YYYY)"
If IsDate(txtcurrentdate) Then
If IsDate(txtcurrentdate) < currentdate Then
validcurrentdate = False
currentdateerrmsg = "The current date you have entered have past, make sure that you enter a valid date"
validcurrentdate = True
End If
currentdateerrmsg = "You must enter a date with DD/MM/YYYY format"
End If
End If
End Sub


Date Validating And Calculating
Question:Is there a way to validate a date (Now function). ie. check its in the future and check its a possible date e.g: 45/02/03 isn't posible
Question:Can u also add ten seconds to a date (Now function) and check if its smaller or higher than another date
I am using strings in each instance but can change easily

Thanks in advance

Validating DATE And Numbers
i have two questions.

ive tried two ways..

1) ive tried the masked edit box using ##/##/##

it works except when i press ADD (which is suppose to clear fields) all the other fields clear except the masked edit box.

how do i get it to clear the masked edit box to ##/##/##

for example from 10/11/03 to clear and show ##/##/## when i press ADD

2) ive validated the date text box using ASCII keys so that the user can only enter in numbers, no alpha characters.
but it wont let me backspace or delete after entering number... how do i make it so i can delete the number ive entered????

Date Picker
I am using DTPicker and want to be able to do 2 things:

1. Display a blank or null date (without using check box)

2. Skip forward and back by years as well as months.

Can anyone help?

Date Picker For VBA
I haven't been in VBA for a while now and I've never used the date picker...

Is a date picker available in VBA?
If so, what is the syntax for it?
What components do I need to add for it?

This would help me out greatly!

About Date Picker In Vba
Hi there. I recently added a "monthview" tool to my excel application in vba (by registering "regsvr32 mscomct2.ocx" in which a monthview tool was added to the component tool in the vb editor). However when I used the excel application in other machine, it prompted me with an error message and the application could not be run. Must I install the same ocx file in any machine which is to run my excel application?


Date Picker
How do I get Date picker to show the current date?
I mean as the default start value

DT Picker = Date ?
I have just recently switched from a Tet box to a Date Time Picker> What happens was when the Text in the text box = todays date, a custom form is shown. This was the code I used:

Private Sub txtCustomerName_Change()

If Text1.Text = Date Then
End If

I tried using this code on my Date Picker Control but it never worked.

Does anyone know the solution?


Date Picker
Does anyone know if you can set the checkbox property for the Date Picker to "unchecked"? The default seems to be "checked" with no way to change it.

Thanks a bunch!!!!

Date Picker
hai to all,

i am using a DateTimePicker Control in my form..

During the search condition ..i am allowing the user to enter data in one of the
form fields and after clicking the search button the data has to be displayed in
the form fields..


Can anybody knows the solution..i have to clear the dtpicker control ..

pls send me a maill... expecting ur reply..

Advance thanks to uuu..
Thangaraj A

Date Picker
Hi folks, i'm looking for a time picker like a calender that can act like a input box does someone know where i could find this?

I'll be among the best soon, very soon!!!

Date Picker Asking
I would like to know.. How I can pass the value to datepicker2 when I change the datepicker1 value?

DTPicker1.Value = Format(Now, "dd/MM/yyyy")

Regarding Date Picker
can anybody here help me how to display date picker having no date? i mean, during run time the content of date picker is " / / /". no default date..

Regarding Date Picker
Please help me out how to add the date picker component in the form. I was to trying to add this from the menu Project - Components and I am not able to find it out.

Also please tell from where we can download vb 6.0 latest software for free.


Regarding Date Picker

Pls suggest me from where i can get the date picker control. I am trying in Projects Menu - components and i am not able to find out.

Pls help me

can any body tell from where we can download the latest VB 6.0 software for free.


HElp With DAte Picker
hi everyone! can any of you please help's my problem. i have this IF statement but it seems it doesn't work.

If DtpOut.Value = "" Then
msgbox ....
End If

What i want is, if the value of Dtpout is equal to "" or NULL then execute something....can anybody pls. help me.

Date Picker

I am wondering if someone could help me out. I am using VB6 and Ms Acces.
I am using DatePickers to enter dates into the database.

Format of the datepickers is set to long dates and in the database the dates are set to date/time and longdate also.

But when I click for example 10 March 2005 and 11 March 2005 it goes into the database as october 3 and November 3...

Could someone please help me to fix this?

Date Picker
I'm using VB6.0.I'm using a date picker.In that I want to display the time in 24 hr format.Howz it possible.Cuurently its showing only long time
Pls help me

Getting AGE Using Date Picker
anyone knows how to get the age of the person when i enter his birthday on the datepicker.. assuming its on mm/dd/yy format..


Date Picker
I get error if i use the following statement


Date Picker
Is there a way to not allow a user to select a certain date range, for instance, can't select a data greater than today?? Thanks

Date Picker
Can u give me the logic.
or Code for the datepicker

Date Picker
I've put a date time picker on my form and after setting the date I then write that to a database field which was already set to nvarchar. As I already have alot of clients in the table I cannot alter the format of that field. However, everythings fine exept that it write the date to the field with the month first then the day and misses off the 0's

Example: if the date was 01/12/2003 it would write it to the field 12/1/2003.

Can you help?


Vb 6 Date Picker
hello there vb people...
i had a problem with the date picker...
right now am doing my case study about Hotel Reservation and my question is as follows
1. i have a record on my access database for ArrivalDate and DepartureDate of every HotelGuest in each RoomNo
2. if a new HotelGuest comes in and wants to make a reservation on the same roomno... how can i track it... below if my sample vb code and it does not work...

Private Sub Command1_Click()
If dtArrive.Value > newDateReserve.Value And newDateReserve < DTDepart.Value Then
Text1.Text = "true"
Text1.Text = "false"
End If
End Sub

pls help.. thanks


Date Picker

I am trying to use the below query to filter records by date from a table, its not working from VB6, also to make it easier to the user, i need to use the date picker. when I run the query i recive the error , invalid coulmn name 'Aug' aug = month name, augest

Adodc1.RecordSource = " select * from unitfixes where dateinput between " & (DTPicker1.Value) & " and " & (DTPicker2.Value) & ""

Any help will be appreciated


Date Picker
I want to make the fore text colour of the DatePicker as Blue. Please suggest how to change this property.

Validating A Date In A Compound IF Statement
I need to validate a date entered into a textbox in the form mm/dd/yy by using a massive compound IF statement. If the date is valid, nothing happens but if an invalid date is entered, a message box pops up saying, "invalid date."

this is what I have so far:

fulldate= txtdate.text
month = fulldate.Substring(0, 2)
day = fulldate.Substring(3, 2)
year = fulldate.Substring(6, 2)

If (month < 1 Or month > 12) Or (day < 1 Or day > 31) Or (year > 3 And year < 38) Or (month = 4 And day > 30) Or (month = 6 And day > 30) Or (month = 9 And day > 30) Or (month = 11 And day > 30) Then
MsgBox("Invalid Date Entered", , "Data Entry Error")
Exit Sub
End If
I've tried a lot of different things to do the leapyear and non leapyear calculations but nothing works.

Help Needed Validating Date Entries
OK... I've got a grid which the user can enter two cols worht of data.... the first col is a Date... then second is a dollar amount.
checking the amount col for valid data is straight forward... it's either a number or it isn't.
Checking the date is another matter.
We want them to enter the date in a mm/dd/yyyy format....
at the moment, I'm using the IsDate to check for valid dates.... it will catch really bad dates like "12/32/298855"
BUT.... it's not catching things like "7.05.03"... which it translates to 07:05:03AM..... grrr.....
ANy one have any ideas?

Validating Date Entered To Period Entered (which Corresponds To A Date Range)
I am trying to create a macro in excel that compares a date entered (YYYYMMDD) and a period entered (1-13) to see if the date entered matches the dates of the period entered?

(E.g. Date - Cell B3 = Entered 20040412 (YYYYMMDD)
        Period - Cell B4 = Entered 12
        Since period 12 respective dates are 20040404 thru 20040501 macro should return message saying valid date and period

         Date - Cell B3 = Entered 20040412
        Period - Cell B4 = Entered 11
        Since period 11 respective dates are 20040307 thru 20040402 macro should return message saying invalid - date and period do not match)

edit:: Moved to VBA (Sorry, I have no answer for you)

Edited by - Metallisoft on 4/13/2004 11:04:34 AM

Date Picker In DataGrid
Hello Again,

Can Someone Out There Have an Idea To Use Date Picker In DataGrid.


Date Time Picker
I need to have the year from the date time picker to be formatted as YY. Could someone help me with the syntax on doing this?

Also, Is this an efficient/logical way of doing this? I have 3 separate text boxes in which the user can either enter the date in or select it from the DTP form.

Private Sub dtpickerLbl_Click()
monthTxt.Text = dtpFrm.dtpCal.Month
dayTxt.Text = dtpFrm.dtpCal.Day
yearTxt.Text = Format(dtpickerFrm.dtpCal.Year, YY) ...This ain't working...
End Sub

Date Time Picker
Can the value of the date time picker be left blank? My reason for asking this is so that I can use this for entering Date of Birth and want to default it to blank.

Can someone help?

Faster Date Picker
hey, have you ever noticed how slow is date picker to change it's value after you changed it's text? is there anyway to make it faster? because as slow as it is, i have the time to close 5 time my form and load the wrong value before it update itself...

Copyright 2005-08, All rights reserved