In the QuerySave event of my form a validation takes place, I get kicked back out to the view. Can someone tell me what I am doing wrong or what I am missing because this is not working and the document keeps getting saved when it should not if there is a validation msg. By the way is there a way that only one msg (one that includes all the validation msgs in one list) 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")
Continue = False
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")
Continue = False
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")
Continue = False
End If
If doc.Names(0) = “” Then
Msgbox “Missing entry for Person visited!”, MB_ICONSTOP, “Save & Close”
’source.GoToField (" Names")
Continue = False
End If
If doc.Region(0) = “” Then
Msgbox “Missing entry for Region!”, MB_ICONSTOP, “Save & Close”
’source.GoToField (“Region”)
Continue = False
End If
If doc.Location(0) = “” Then
Msgbox “Missing entry for Location!”, MB_ICONSTOP, “Save & Close”
’source.GoToField (“Location”)
Continue = False
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