Solved

Date checking problem

Posted on 1998-11-10
5
135 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…
Suggested Courses
Course of the Month8 days, 15 hours left to enroll

615 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