PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook VBA Programming Most recent date ....

Reply

Most recent date ....

 
Thread Tools Rate Thread
Old 04-03-2005, 02:09 PM   #1
Wanda
Guest
 
Posts: n/a
Default Most recent date ....


I have 6 date fields and I want to be able to have a temp
field that determines the latest date .... is there code
that can do this? I could then link the temp field to
the main page where it is needed. I'm thinking that I
need to use an IF statement, but I am not sure how to do
the logic for that after the first 2 fields.

Thanks.

Wanda
  Reply With Quote
Old 04-03-2005, 03:49 PM   #2
=?Utf-8?B?RXJpYyBMZWdhdWx0IFtNVlAgLSBPdXRsb29rXQ==
Guest
 
Posts: n/a
Default RE: Most recent date ....

Do you have a sample of your code so far that you can show us?

If you want to add a field on the fly, add one to the Item.UserProperties
collection.

To do date comparisons, use the DateDiff function:

Dim date1 As Date, date2 As Date

date1 = #1/1/2005#
date2 = #1/2/2005#

If DateDiff("y", date1, date2) > 0 Then
'If date1 refers to a later point in time than date2, the DateDiff
function returns a negative number.
Debug.Print "date1 is earlier than date2 using day of year as a
comparison"
Else
Debug.Print "date2 is later than date1 using day of year as a
comparison"
End If

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/

"Wanda" wrote:

> I have 6 date fields and I want to be able to have a temp
> field that determines the latest date .... is there code
> that can do this? I could then link the temp field to
> the main page where it is needed. I'm thinking that I
> need to use an IF statement, but I am not sure how to do
> the logic for that after the first 2 fields.
>
> Thanks.
>
> Wanda
>

  Reply With Quote
Old 04-03-2005, 08:48 PM   #3
Wanda
Guest
 
Posts: n/a
Default RE: Most recent date ....

I don't know why I was making it harder then it needed to
be. I have it working now and instead of using manual
written code, I used code through the objects.

I defaulted all date fields to January 1, 1900. As the
client needs to change the date, I have hidden objects
that look at the first and second date and calculate which
is the latest, then an object that looks at A (first and
second calculation field) and populates B object .... and
so on. The very last object (field) is linked to the
main page with a visible date showing of the latest date
entered. On the hidden objects to do the calculations, I
made the Type = Date, Fomat = Month day, Year ... then
I "set initial value of field to" = IIf( expr ,
truepart , falsepart ), and clicked on the radio
button "calculate formula automatically".

It works like a charm. I'll keep the "DateDiff" in mind
for other forms. Thanks very much.

Wanda
>-----Original Message-----
>Do you have a sample of your code so far that you can

show us?
>
>If you want to add a field on the fly, add one to the

Item.UserProperties
>collection.
>
>To do date comparisons, use the DateDiff function:
>
> Dim date1 As Date, date2 As Date
>
> date1 = #1/1/2005#
> date2 = #1/2/2005#
>
> If DateDiff("y", date1, date2) > 0 Then
> 'If date1 refers to a later point in time than

date2, the DateDiff
>function returns a negative number.
> Debug.Print "date1 is earlier than date2 using

day of year as a
>comparison"
> Else
> Debug.Print "date2 is later than date1 using day

of year as a
>comparison"
> End If
>
>--
>Eric Legault - B.A, MCP, MCSD, Outlook MVP
>--------------------------------------------------
>{Private e-mails ignored}
>Job: http://www.imaginets.com
>Blog: http://blogs.officezealot.com/legault/
>
>"Wanda" wrote:
>
>> I have 6 date fields and I want to be able to have a

temp
>> field that determines the latest date .... is there

code
>> that can do this? I could then link the temp field to
>> the main page where it is needed. I'm thinking that I
>> need to use an IF statement, but I am not sure how to

do
>> the logic for that after the first 2 fields.
>>
>> Thanks.
>>
>> Wanda
>>

>.
>

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off