Month/year selection prompt to return a clean date value

Prompt's the user for a month/year within the last 12 months, Returns a date value equal to the first day of the selected Month/Year. Used in the "Save and Close" button in the "SBD Report" form of the iTeam Marketing Database.
LotusScript


Dim x As Integer
Dim J As Integer
J = 11
			
Dim DateArray(11) As String
Dim MonthArray(11) As String
			
For x = 0 To 11
	Set newdate = New NotesDateTime(Today)
	Call newdate.AdjustMonth(-J)
	DateArray(x) = Month(newdate.lslocaltime) & "/" & 1 & "/" & Year(newdate.lslocaltime)
	MonthArray(x) = GetMonthAndYear(J)
	J = J - 1
Next
			
Dim SelectedMonth As Variant
	
Do While SelectedMonth = ""
	SelectedMonth = workspace.Prompt( PROMPT_OKCANCELLIST, "Choose Month", "Please select a month/year for the report categorization.", MonthArray(11) ,  MonthArray )
Loop
			
Dim FinalDate As String
			
Select Case SelectedMonth
Case MonthArray(0)  : thisdoc.PostedDate = Cdat(DateArray(0))
Case MonthArray(1)  : thisdoc.PostedDate = Cdat(DateArray(1))
Case MonthArray(2)  : thisdoc.PostedDate = Cdat(DateArray(2))
Case MonthArray(3)  : thisdoc.PostedDate = Cdat(DateArray(3))
Case MonthArray(4)  : thisdoc.PostedDate = Cdat(DateArray(4))
Case MonthArray(5)  : thisdoc.PostedDate = Cdat(DateArray(5))
Case MonthArray(6)  : thisdoc.PostedDate = Cdat(DateArray(6))
Case MonthArray(7)  : thisdoc.PostedDate = Cdat(DateArray(7))
Case MonthArray(8)  : thisdoc.PostedDate = Cdat(DateArray(8))
Case MonthArray(9)  : thisdoc.PostedDate = Cdat(DateArray(9))
Case MonthArray(10)  : thisdoc.PostedDate = Cdat(DateArray(10))
Case MonthArray(11)  : thisdoc.PostedDate = Cdat(DateArray(11))
End Select
			
Call thisdoc.Save(True, True)	


Function GetMonthAndYear(NumberBack As Integer) As String
	
	Set newdate = New NotesDateTime(Today)
	Call newdate.AdjustMonth(-(NumberBack))
	
	Dim MonthInteger As Integer
	MonthInteger = Month(newdate.lslocaltime)
	Dim MonthText As String
	
	Select Case MonthInteger
		
	Case 1    : MonthText = "January"
	Case 2    : MonthText = "February"
	Case 3    : MonthText = "March"
	Case 4    : MonthText = "April"
	Case 5    : MonthText = "May"
	Case 6    : MonthText = "June"
	Case 7    : MonthText = "July"
	Case 8    : MonthText = "August"
	Case 9    : MonthText = "September"
	Case 10  : MonthText = "October"
	Case 11  : MonthText = "November"
	Case 12  : MonthText = "December"
		
	End Select
	
	GetMonthAndYear = MonthText & " " & Year(newdate.lslocaltime)
	
End Function

Images/Screenshots:

Posted by fbrefere001 on Thursday April 4, 2002