Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Date checking problem

Posted on 1998-11-10
5
Medium Priority
?
138 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 100 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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

971 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