Hi,I have 3 Fields:
From (Edit Field)
To (Edit Field)
Period (computed field).
What I would like to do is:
When I select
From = 01/01/2005
To= 30/01/2005
Period will be equal to 01 automaically.
How to do that?
Thanks
Hi,I have 3 Fields:
From (Edit Field)
To (Edit Field)
Period (computed field).
What I would like to do is:
When I select
From = 01/01/2005
To= 30/01/2005
Period will be equal to 01 automaically.
How to do that?
Thanks
Subject: Computed Date Field
Is Period the month? How do you determine what the Period is?
Subject: RE: Computed Date Field
Ok,for example: between from = 01/01/2005 and to= 31/01/2005 so period = 1
between from = 02/02/2005 and to= 31/02/2005 so period = 2 …
Subject: RE: Computed Date Field
How about using @month then?
Cheers,
Mark
Subject: RE: Computed Date Field
I have no idea.Could you help me with a formula
Subject: RE: Computed Date Field
Assuming From and To are both in the same month, then the fomula for Period would be
@Month(From)
Now, for this to work, From has to be a date/time value.
If you need the Period value to have a leading 0, then you should define Period as Text, and use the following formula instead:
@Right(“0” + @Text(@Month(From));2)
Subject: RE: Computed Date Field
But sorry that’s not really what I want cause we have like 26 periods in a year and it depends on which date here’s some examples:
Periode_Num Period Starting Date Ending Date
1 1 01-Apr-05 30-Apr-05
2 2 01-May-05 28-May-05
3 3 29-May-05 25-Jun-05
4 4 26-Jun-05 23-Jul-05
5 5 24-Jul-05 20-Aug-05
6 6 21-Aug-05 17-Sep-05
7 7 18-Sep-05 15-Oct-05
8 8 16-Oct-05 12-Nov-05
9 9 13-Nov-05 10-Dec-05
10 10 11-Dec-05 07-Jan-06
11 11 08-Jan-06 04-Feb-06
12 12 05-Feb-06 04-Mar-06
13 13 05-Mar-06 31-Mar-06
Subject: RE: Computed Date Field
Based on this info, I would probably handle it in the QuerySave event of the form, with something like this:
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim doc As NotesDocument
Set doc = source.Document
FromMD$ = Format$(doc.FromDate(0), "mmdd")
ToMD$ = Format$(doc.ToDate(0), "mmdd")
If FromMD$ >= "0401" And ToMD$ <= "0430" Then
Period$ = "01"
Elseif FromMD$ >= "0501" And ToMD$ <= "0528" Then
Period$ = "02"
Elseif FromMD$ >= "0529" And ToMD$ <= "0625" Then
Period$ = "03"
End If
doc.Period = Period$
End Sub
Subject: RE: Computed Date Field
mY FIELD ARE:BeginningDate
EndDate
Period
Period should be computed?
Thanks for your help, I really appreciate
Subject: RE: Computed Date Field
Yes, should be computed. If field name is Period, then formula for field should be just the field name Period.
Going the route I suggested, the field is non-editable since you will be populating it on the back-end document when the doc is being saved.
Something else to think of. If none of the From and To dates match, then you should display a msg to user to that effect and set Continue to False so the doc won’t save.
FromMD$ = Format$(doc.FromDate(0), “mmdd”)
ToMD$ = Format$(doc.ToDate(0), “mmdd”)
Period$ = “”
If FromMD$ >= “0401” And ToMD$ <= “0430” Then
Period$ = “01”
Elseif FromMD$ >= “0501” And ToMD$ <= “0528” Then
Period$ = “02”
Elseif FromMD$ >= “0529” And ToMD$ <= “0625” Then
Period$ = “03”
End If
If Period$ = “” then
msgbox “Your Error Msg here”
Continue = False
else
doc.Period = Period$
End if
Subject: RE: Computed Date Field
Thanks so much Jerry, it’s working great