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 )

7 Years
Discussion Span
Last Post by schanglani

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

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



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
If Trim$(Replace(dt.Text,"/","")) = "" Then
msgbox "XXXX"
End if

I Think This should solve your problem

Satish Changlani

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.