Solved

Date checking problem

Posted on 1998-11-10
5
130 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
Comment Utility
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
Comment Utility
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
Comment Utility
Hi,
how about date format settings in W95?

Bye.
0
 
LVL 1

Expert Comment

by:pietjepuk
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

763 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

9 Experts available now in Live!

Get 1:1 Help Now