Auto updating yes/no fields

G

Guest

Hello there;

I'm working with a table that has the following structure:

strID => person's ID
dtmStrDate => date when person started working
dtmEndDate => date when person finished work
ysnActive => Status for that person

What I would like to know is if there's a way to make the yes/no field auto
update using the following rule:

if (dtmStrDate <= today() <= dtmEndDate) then ysnActive=True else
ysnActive=False

Thanks in advance.
 
J

John W. Vinson

Hello there;

I'm working with a table that has the following structure:

strID => person's ID
dtmStrDate => date when person started working
dtmEndDate => date when person finished work
ysnActive => Status for that person

What I would like to know is if there's a way to make the yes/no field auto
update using the following rule:

if (dtmStrDate <= today() <= dtmEndDate) then ysnActive=True else
ysnActive=False

Thanks in advance.

I'd suggest that, unless the Status can sometimes be False even though today's
date is in the range and sometimes be True otherwise, that the field ysnActive
should *simply not exist*. Since its value can be derived from the date
fields, just calculate it as needed. In a Query you can use an expression:

ysnActive: (dtmStrDate < Date() AND NZ(dtmEndDate, Date()) >= Date())

This assumes that dtmEndDate might be NULL and if so you want the person to
still be considered active.

If I've misinterpreted the meaning of ysnActive post back.

John W. Vinson [MVP]
 
G

Guest

John W. Vinson said:
I'd suggest that, unless the Status can sometimes be False even though today's
date is in the range and sometimes be True otherwise, that the field ysnActive
should *simply not exist*. Since its value can be derived from the date
fields, just calculate it as needed. In a Query you can use an expression:

ysnActive: (dtmStrDate < Date() AND NZ(dtmEndDate, Date()) >= Date())

This assumes that dtmEndDate might be NULL and if so you want the person to
still be considered active.

If I've misinterpreted the meaning of ysnActive post back.

John W. Vinson [MVP]

Actually, your suggestion works very well so far. I have to change some
relationships and queries but overall it works as intended.

Thanks again for your help Mr. Vinson.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top