|
-
Nov 19th, 2001, 04:36 AM
#1
Thread Starter
Addicted Member
IsDate Format Date
I need some help here. It is about format date on IsDate Function. It seems, that i can't get it right. I hope you can assist me on this. This is what i am trying to achieve. User Input a date in MskEffective Date and automatically Isdate function generate an Expiry Date in MskExpiry. My Problem is each time i enter an effective date it prompt me an Error stated Invalid Property Value on <<FormName.mskExpiry = YearDate - 1>>. Below are my coding. I believe it is my coding problem. I have solved a couple of Error on Date but not this time. I am appreciate with anyone help. Thank you in advance.
VB Code:
Public Sub Validate(FormName As Form)
IntervalY = "yyyy"
If IsDate(FormName.mskEffective) = False Then
MsgBox "Date Wrong Format.Please check Date", vbCritical, "Date Format Incorrect"
FormName.mskEffective.SetFocus
Exit Sub
End If
FirstDate = FormName.mskEffective
'FirstDate = Format(FirstDate, "dd-mm-yyyy")
number = 1
YearDate = DateAdd(IntervalY, number, FirstDate)
'YearDate = Format(FirstDate, "dd-mm-yyyy")
'FormName.mskExpiry = Format(FormName.mskExpiry, "dd-mm-yyyy")
FormName.mskExpiry = YearDate - 1 'ExpiryDate Must Minus One Day
End Sub
As you can see there are couple of Remarks which i tested out but all fail.
-
Nov 19th, 2001, 04:46 AM
#2
Fanatic Member
DO NOT USE IsDate Function,it is very "bad"
-
Nov 19th, 2001, 04:51 AM
#3
Thread Starter
Addicted Member
-
Nov 19th, 2001, 04:57 AM
#4
-= B u g S l a y e r =-
Originally posted by dongaman
DO NOT USE IsDate Function,it is very "bad"
why?
-
Nov 19th, 2001, 05:00 AM
#5
Fanatic Member
-
Nov 19th, 2001, 05:02 AM
#6
Thread Starter
Addicted Member
Well, my question is about Format Date with IsDate function.
-
Nov 19th, 2001, 05:05 AM
#7
Thread Starter
Addicted Member
i dont get u, dongaman.
-
Nov 19th, 2001, 05:05 AM
#8
Fanatic Member
To peet.
Such as:
IsDate("01-22-02")=true 'in yy-mm-dd "01-22-02" is not valid
-
Nov 19th, 2001, 05:10 AM
#9
No! Please continue to use the IsDate function.
Besides as I understand your question the error is raised on this line:
VB Code:
FormName.mskExpiry = YearDate - 1
You might want to try changing the line with DateAdd instead to substract one day.
VB Code:
YearDate = DateAdd("d", -1, DateAdd(IntervalY, number, FirstDate))
Best regards
-
Nov 19th, 2001, 05:15 AM
#10
Fanatic Member
To Joacim Andersson.
Do you want IsDate(01-22-33)=true
-
Nov 19th, 2001, 05:19 AM
#11
Originally posted by dongaman
To Joacim Andersson.
Do you want IsDate(01-22-33)=true
As I understand it kokzai using the format dd-mm-yyyy in his masked edit controls so this wouldn't be an issue.
-
Nov 19th, 2001, 05:27 AM
#12
Thread Starter
Addicted Member
Opss...
VB Code:
FormName.mskEffective = DateAdd("d", -1, DateAdd(IntervalY, number, FirstDate))
it still hit the same Error.
Joacim Andersson, it is not the - 1 gave me the Error. Previously, it work fine until i changed my System Date. I do not which to rely on the System Date too much. I rather my application to accpet any format changes on system.Basically, it is the Format Date caused the Error.
I have solved a couple of Same Error with Format Date but this time i Fail
-
Nov 19th, 2001, 05:31 AM
#13
I can't see the declaration of YearDate in your code. What kind of data type does it have?
-
Nov 19th, 2001, 05:32 AM
#14
Registered User
isdate answer
i saw your coding i think u have made mistake in isdate function
first parametr is string so u have to "d" or "m"or "yyyy"in first parameter.
-
Nov 19th, 2001, 05:33 AM
#15
Thread Starter
Addicted Member
-
Nov 19th, 2001, 05:37 AM
#16
OK! A Date always contains both a date and time value so you can't assign that to your masked edit control since it's not the correct format.
VB Code:
FormName.mskExpiry.Text = Format$(YearDate - 1, "dd-mm-yyyy")
Best regards
-
Nov 19th, 2001, 05:42 AM
#17
Thread Starter
Addicted Member
Well, Thanks Joacim Andersson. It works with no Error. But the output is not accurate.
It should be + 1 Year and Then - (minus) One Day = mskExpiry.
-
Nov 19th, 2001, 06:41 AM
#18
Try this
VB Code:
Public Sub Validate(FormName As Form)
IntervalY = "yyyy"
If IsDate(FormName.mskEffective) = False Then
MsgBox "Date Wrong Format.Please check Date", vbCritical, "Date Format Incorrect"
FormName.mskEffective.SetFocus
Exit Sub
End If
FirstDate = FormName.mskEffective
number = 1
YearDate = DateAdd("d", -1, DateAdd(IntervalY, number, FirstDate))
FormName.mskExpiry.Text = Format$(YearDate, "dd-mm-yyyy")
End Sub
Best regards
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|