Comparing Dates in Forms

J

Jonathan Pinto

I am trying to compare some dates in a form, to the current date.
Here are some fields in my form:

DocOwnerRevDate - Document Owner Review Date
DocOwnerDate - Document Owner Date

OCARRevDate - Operations Committee Review Date
OCARDate - Operations Committee Date

OpenClosed - Signifies Whether Project is Open or Closed


Dates will be filled into the date fields. If the DocOwnerRevDate
field is less than the current date, then I would like the text in
that field (the label and field itself) to turn RED. That is unless
the DocOwnerDate field is filled in. If the DocOwnerDate field is
filled in, then text should appear as normal (in black font, etc.). I
would like the same done with the OCARRevDate and the OCARDate fields.
I have tried putting some code in the OnCurrent event of the form,
and was able to get the text and label to turn red, but that is just
based on whether or not the DocOwnerDate is NULL. I am unable to put
any other stipulation in there, to compare the DocOwnerRevDate to the
current date. Finally, all of these criteria are dependant upon
whether or not the job is Open. If the job is Closed, then none of
this should take place.

Example:

DocOwnerRevDate: 6/17/2004 (current date happens to be 7/26/2004)
DocOwnerDate has not been filled in.
OUTCOME ON FORM SHOULD BE THAT THE DocOwnerRevDate field turns RED.

Any help on this issue would be greatly appreciated!

Thanks in advance,


Jonathan
 
B

berk

Try this.

this is assuming that there is a checkbox or somthing
similar that would identify if a job is open or not.

on the onCurrent event, type checkDate (which will go to
the sub you are about to write)

in the code for the same page after one of the sub
functions, start typing this.

sub checkDate()
if jobisopen = false then
lbl_docownerrevdate.forecolor = vbblack
txt_docownerrevdate.forecolor = vbblack
Exit sub
else
if len(docownerdate) > 0 then
lbl_docownerrevdate.forecolor = vbblack
txt_docownerrevdate.forecolor = vbblack
exit sub
else
if docownerrevdate < date then
lbl_docownerrevdate.forecolor = vbred
txt_docownerrevdate.forecolor = vbred
'not sure what the names are
'for the field or label
else
lbl_docownerrevdate.forecolor = vbred
txt_docownerrevdate.forecolor = vbred
end if
end if
end if

' you would also want to run this code after you put the
date in the docownerdate field. so, type checkdate in the
afterupdate event for docownerdate.

I hope I understood your question and this works.
 

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