verification of date input in field

  • Thread starter Thread starter W
  • Start date Start date
W

W

Hi,

I have several dat fields in a form. All dates are vital to the
application, so I do not want to go to the next field until a valid date is
been filled in.
I want to do that with te AfterUpdateEvent, something like :

Dim dDate as date
if me.DateOne.value is null or isnull(me.dateOne).value then
beep
msgbox ("some text")
me.DateOne.setfocus
else
dDate = me.DateOne.value
me.NextDate.setfocus
endif

This does not work.
Anyone a clue ?

Thank you very much,

W
 
W said:
Hi,

I have several dat fields in a form. All dates are vital to the
application, so I do not want to go to the next field until a valid date
is
been filled in.
I want to do that with te AfterUpdateEvent, something like :

Dim dDate as date
if me.DateOne.value is null or isnull(me.dateOne).value then
beep
msgbox ("some text")
me.DateOne.setfocus
else
dDate = me.DateOne.value
me.NextDate.setfocus
endif

This does not work.
Anyone a clue ?

Thank you very much,

W

This line:

if me.DateOne.value is null or isnull(me.dateOne).value then

needs to read:

if isnull(me.dateOne).value then

The 'Is Null' construct only works when it is parsed by the Access
expression service, such as in a query. For VBA, just use the IsNull
function.
 
Sorry, but this

if isnull(me.dateOne).value then

is still incorrect!

It should be

if isnull(me.dateOne.value) then

or since .Value is the default property for a textbox

if isnull(me.dateOne) then

will actually be fine.
 
Linq Adams via AccessMonster.com said:
Sorry, but this

if isnull(me.dateOne).value then

is still incorrect!

It should be

if isnull(me.dateOne.value) then

or since .Value is the default property for a textbox

if isnull(me.dateOne) then

will actually be fine.

Good catch. I totally missed that. humph!
 
Stuart McCall said:
This line:

if me.DateOne.value is null or isnull(me.dateOne).value then

needs to read:

if isnull(me.dateOne).value then

The 'Is Null' construct only works when it is parsed by the Access
expression service, such as in a query. For VBA, just use the IsNull
function.
Sorry, typing error. But : isnull(me.dateOne.value) does not work either.
So I'm stuck with my problem.

W
 
W said:
Sorry, typing error. But : isnull(me.dateOne.value) does not work either.
So I'm stuck with my problem.

W

Hmm, I'm wondering if zero-length strings may be causing trouble. Try this:

If Len(Me.dateOne.Value & "") = 0 Then
 
Back
Top