PC Review
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Most recent date ....
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Most recent date ....
![]() |
Most recent date .... |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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 > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
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 >> >. > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

