Subject: RE: Hide whens can quickly solve this…
Hi Radio Head,thanks for your suggestion. I attempted something in the QuerySave event of the form but after the validation takes place, I get kivked out of the application. By the way is there a way that only one msg be presented on the screen and then return the user to the appropriate field (I have never done that)?
Thanks,
Dan
Here is what I have:
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim s As New NotesSession
Dim db As NotesDatabase
Dim w As New NotesUIWorkspace
Dim doc As NotesDocument
Dim item As NotesItem
Dim dt As NotesDateTime
Set db = s.CurrentDatabase
Set doc = Source.Document
bSaved = False
'Dont let it save until continue = true
Continue = False
‘XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
'validate entries
If doc.Status(0) = "" And doc.VisitorName(0) = "" Then
Msgbox "Missing entry for Visitor Name!", MB_ICONSTOP, "Save & Close"
source.GoToField (" VisitorName")
Else
If doc.Status(0) = "New/Nouveau" And doc.NewVisitorName(0) = "" Then
Msgbox "Missing entry for Visitor Name!", MB_ICONSTOP, "Save & Close"
source.GoToField (" NewVisitorName")
End If
End If
If doc.Status(0) = "New/Nouveau" And doc.NewCompanyName(0) = "" Then
Msgbox "Missing entry for Company Name!", MB_ICONSTOP, "Save & Close"
source.GoToField (" CompanyName")
End If
If doc.Names(0) = "" Then
Msgbox "Missing entry for Person visited!", MB_ICONSTOP, "Save & Close"
source.GoToField (" Names")
End If
If doc.Region(0) = "" Then
Msgbox "Missing entry for Region!", MB_ICONSTOP, "Save & Close"
source.GoToField ("Region")
End If
If doc.Location(0) = "" Then
Msgbox "Missing entry for Location!", MB_ICONSTOP, "Save & Close"
source.GoToField ("Location")
End If
‘XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Set dt = New NotesDateTime("1/1/1980")
Call dt.SetNow()
Set item = doc.ReplaceItemValue( "ModifyDate", dt.LSLocalTime)
Set item = doc.ReplaceItemValue( "Modifier", s.CommonUserName)
'set the date fields so they have the time after them
Set dt = New NotesDateTime(doc.AwayFrom(0))
Set item = doc.ReplaceItemValue( "AwayFrom", dt.LSLocalTime)
Set dt = New NotesDateTime(doc.BackOn(0))
Set item = doc.ReplaceItemValue( "BackOn", dt.LSLocalTime)
Set dt = New NotesDateTime(doc.AwayFromTime(0))
Set item = doc.ReplaceItemValue( "AwayFromTime", dt.TimeOnly)
Set dt = New NotesDateTime(doc.BackOnTime(0))
Set item = doc.ReplaceItemValue( "BackOnTime", dt.TimeOnly)
'all OK
Continue = True
bSaved = True
'==============================================================
'Msgbox( "Strarting Agent - NewVisitorProfile_Notes ")
’ Handle New Visitor Request
'If the Status field is = “New” then create a separate visitor profile document
'Msgbox( "Break 1")
If ( doc.Status(0) = "New/Nouveau" ) Then
FName$ = doc.FName(0)
LName$ = doc.LName(0)
CompanyName$ = doc.CompanyName(0)
CompanyAddress$ = doc.CompanyAddress(0)
CompanyCity$ = doc.CompanyCity(0)
CompanyProvState$ = doc.CompanyProvState(0)
CompanyPostalCode$ = doc.CompanyPostalCode(0)
CompanyPhone$ = doc.CompanyPhone(0)
CompanyFax$ = doc.CompanyFax(0)
CompanyCell$ = doc.CompanyCell(0)
Dim profiledoc As NotesDocument
Set profiledoc = db.CreateDocument
'Msgbox( "Break 2")
'Pass the values from the current web document to the Visitor Information Profile form and save it
profiledoc.Form = "Visitor Information"
profiledoc.FirstName = FName$
profiledoc.LastName = LName$
profiledoc.CompanyName = CompanyName$
profiledoc.MainAddress = CompanyAddress$
profiledoc.City = CompanyCity$
profiledoc.Province = CompanyProvState$
profiledoc.PostCode = CompanyPostalCode$
profiledoc.PhoneNum = CompanyPhone$
profiledoc.FaxNum = CompanyFax$
profiledoc.CellNum = CompanyCell$
'Msgbox( "Break 3")
Call profiledoc.Save(True,True)
End If
'Msgbox( "Ending Agent - NewVisitorProfile")
'===================================================================
End Sub