Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date question

Status
Not open for further replies.

eussias

Programmer
Sep 25, 2001
97
0
0
AU
Does anyone know how I can display a message box when a particular form is loaded and it is the last day of the month.??? :cool:
 
Is this What you need?


You don't state where you need this to happen so where ever you need to trigger it

I have done it using todays date and +9 to trigger the result - replace the 9 with a 1 when you are happy with the functionality.

Put the 2 functions below in a module and the following line where you need to trigger the check



if isloaded("frmname") = true and LOM = true then msgbox "Today is the last day of the month"



Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is open in Form view or Datasheet view.

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If

End Function

Function LOM as Boolean
Dim MonthNum As Integer
Dim checkMonthNum As Integer
LOM = false

MonthNum = DatePart(&quot;m&quot;, Date)
checkMonthNum = DatePart(&quot;m&quot;, Date + 9)
If checkMonthNum - MonthNum = 1 Then LOM = True

end function

regards

jo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top