Wednesday, May 07, 2008

Evaluation of database

Simple example, how we can evaluation of database. Put this code in DatabaseScript on event PostOpen. I would like to see another examples, but I did not find

(Declarations)

Declare Function NEMGetCurrentSubprogramWindow Lib "nnotesws.dll" () As Long
Declare Function NEMStopSubprogramWindow Lib "nnotesws.dll" (Byval hwnd As Long) As Integer
Sub Postopen(Source As Notesuidatabase)
If Cdat("03/15/2009") < Cdat(Today) Then
Dim wHandle As Long
' Get window handle
wHandle = NEMGetCurrentSubprogramWindow
' Close current window
Call NEMStopSubprogramWindow(wHandle)
End If
End Sub

Add on by Olli Kämäräinen
We have to remember about international date, so here a solution how to fix potential problem...

Function MakeDate(dd As String, mm As String, yyyy As String) As Variant

Dim session As New NotesSession
Dim international As NotesInternational
Dim delim As String
Set international = session.International

delim = international.DateSep

If international.IsDateDMY Then
MakeDate = Cdat(dd & delim & mm & delim & yyyy)
'Messagebox "DMY",, "Format of date"
Elseif international.IsDateMDY Then
MakeDate = Cdat(mm & delim & dd & delim & yyyy)
Elseif international.IsDateYMD Then
MakeDate = Cdat(yyyy & delim & mm & delim & dd)
Else
'Messagebox "Unknown",, "Date"
End
End If

End Function

1 comment :

Anonymous said...

Very helpful - works fine - thx