Solved

Date checking problem

Posted on 1998-11-10
5
134 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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.
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.
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…
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…

733 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