
DATABASE
Print a greeting in the status bar
Geert Broeckx 08.07.2001
Rating: --- (out of 5)




|
The following code prints a greeting in the status bar when a user enters a database, creates a document at the same time, and prints a goodbye greeting in the status bar when a user exits the database. This can be used by the administrator or developer to track when and who has accessed the database.
Code
Place this code in the Postopen event of the Database Script:
@Command([ToolsRunMacro];"(Salutations)")
Create the agent Salutation with Manually from Agent List set. The agent prints the salutations at the bottom of the status bar based on the time of day (either, morning, afternoon, evening or night). Then it gets the name of the user and creates a history document. The form has only two fields, a UserName field and a CreatedOn field.
Sub Initialize
Dim HistoryDoc As NotesDocument
Dim user_name As String
Set session = New NotesSession
Set db = session.CurrentDatabase
Set ws = New NotesUIWorkspace
Set UIdoc = ws.CurrentDocument
user_name = session.CommonUserName
If Hour(Time) > 0 And Hour(Time) < 12 Then Print
"Good morning " & user_name & " and welcome back."
If Hour(Time) > 12 And Hour(Time) < 17 Then Print
"Good afternoon " & user_name & " and welcome back."
If Hour(Time) > 17 And Hour(Time) < 20 Then Print
"Good evening & user_name & " and welcome back."
If Hour(Time) > 20 And Hour(Time) < 23 Then Print
"Good night " & user_name & " and welcome back."
Set HistoryDoc = New NotesDocument(db)
HistoryDoc.Form = "FM_UserEnterDatabase"
HistoryDoc.UserName = user
HistoryDoc.CreatedOn = Today
Call HistoryDoc.Save(True,False)
End Sub
Place this code in the Queryclose event of the Database Script.
Dim session As New NotesSession
Dim user As String
user = session.CommonUserName
Print "Goodbye " & user & " and have a nice day."
 |

|
|
 |
|
 |