Hi everybody,
I have used one textbox to accept date say (dt.text) in which during form load two forwardslash will appear to accept DD/MM/YYYY type date.
Now when I click a Save command box and if the dt.text box is not filled up with date OR say it has only two forwardslash then it should exit.
I tried the following statement but it did not work-
1. Isnull(dta.text)=false then
Msgbox "xxx"
2. Isnumeric(dta.text)=false then
Msgbox "xxx"
What other syntax could be used.
Pl help me

(keshar )

Recommended Answers

All 6 Replies

how about using ISDATE function.. :)

Goodluck!

if isnull(dt.text)="" or dt.text="" then
msgbox "xxx"
endif

if isnull(dt.text)="" or dt.text="" then
msgbox "xxx"
endif

It passes the statement thinking that dt.text is not null because of forwardslash in the text.
Pl. suggest any other way

(keshar)

See cguan_77's post. They have the right answer.

Good Luck

isdate is a great function and it only BLOWS up when you least want it to, i.e. when the date is bogus.

In order of precedence and with only ONE test per NESTED IF statement

1- test for the variable to have actually been defined unless it's a text box name and then be sure to prepend it with "Me."

2- test for the variable being empty

3- test for it being your bogus insert (2 dashes)

4- only then let the ISDATE function have it

BUT STILL you'll need specific error trapping before the 4th test because ISDATE is buggy and completely relies on windows regional date settings and thus occasionally gets fooled and gives a divide by zero error which is really nasty.

You should try to remove two forward slashes with replace function in vb
Like
If Trim$(Replace(dt.Text,"/","")) = "" Then
msgbox "XXXX"
End if

I Think This should solve your problem

Satish Changlani

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.