Solved

Date checking problem

Posted on 1998-11-10
5
132 Views
Last Modified: 2010-04-30
Hi VB experts,
 I'm doing one program and the must create the report based on 2 input dates by the user.
The problem is, i always want the user type in the dd-mm-yyyy format. But suppose the user enter 1-15-1998 and the next time the user enter 15-1-1998, the isdate function return as TRUE.
But i wanted always to be dd-mm-yyyy and the problem occurs when the user enter either dd or mm as <= 12.

2nd question
when i do filtering in the crystal report, the dd-mm-yyyy format gives problem in case of either dd or mm <=12. the system thinks that the first value is mm. but i want the system to see the first values as dd.

I hope some of you could help asap
Thank you.
bye
0
Comment
Question by:pandav
5 Comments
 
LVL 1

Expert Comment

by:ajmendes
ID: 1444056
Hi,
1st question:
You can format the data input to start.

2nd question:
In the formula you use to filter data, can't you format also this dates?

I hope this helps.
Bye.
0
 

Author Comment

by:pandav
ID: 1444057
Actually, the problem occurs when i use the date format function.
because , when the user enters 1-15-1998 and the next time the user enter 15-1-1998 , both are valid under isdate function.
Then when i do the date format, the value will be wrong .

0
 
LVL 1

Expert Comment

by:ajmendes
ID: 1444058
Hi,
how about date format settings in W95?

Bye.
0
 
LVL 1

Expert Comment

by:pietjepuk
ID: 1444059
I recently had the same problem. If you convert your date input from a textbox to a date, the format will be dependent on your Windows settings. If you use the calendar control (include MS Calendar control 8.0 in VB 5.0) to get the input dates, you'll always get them in the format you choose.
You can still display the dates in the textbox or a label if you want to.
I use Crystal Reports 4.6 and using Format(yourdate, "yyyy,mm,dd") before opening the reports works fine.
0
 
LVL 4

Accepted Solution

by:
anzen earned 50 total points
ID: 1444060
The previous comments are all correct
that is, when You check the date You'd
do something like

    If IsDate(txtDate.Text) Then
       txtDate.Text = Format(CDate(txtDate.Text), "mm-dd-yyyy")
    Else
       ' Anything You need
       Beep
       MsgBox "Invalid date Entered", vbOkOnly Or vbExclamation, "Error !"
       txtDate.Setfocus
    End If

to check and reformat the value as You need.

0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library 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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

803 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