我有一张表格。表单字段在querysave事件中验证。验证是这样的。我有一些字段需要在保存期间进行验证。即,当我单击一个复选框并且不在其字段中输入详细信息时,它应该在保存时显示错误消息框。验证适用于新文档。我的问题是
请帮助我。请不要介意我的问题是否明显而且简单,因为我更新鲜。提前谢谢。
脚本如下, 第一部分计算新文档和secong部分验证字段的ref num,
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim w As New notesuiworkspace
Dim uidoc As notesuidocument
Set uidoc = w.CurrentDocument
Dim SESS As New NotesSession
Dim Doc As NotesDocument
Dim RefView As NotesView
Dim DB As NotesDatabase
Dim RefDoc As NotesDocument
Set DB = SESS.CurrentDatabase
Set Doc = uidoc.Document
Set RefView = DB.GetView("System\AutoNo")
If uidoc.IsNewDoc = True Then
Financial_year = Clng(Right$(Cstr(Year(Now)),3)) + 104
If Month(Now) >= 4 Then Financial_year = Financial_year + 1
Application = "ST"
DefKey$ = Cstr(Financial_year)
DefNo& = 0
Set RefDoc = RefView.GetDocumentByKey(DefKey$ , True)
If Not(RefDoc Is Nothing) Then DefNo& = Clng(Right$(RefDoc.SETTLEMENT_NO(0),5))
DefNo& = DefNo& + 1
RefNo$ = (Application + DefKey$) & "-" & Right$("00000" & Cstr(DefNo&) ,5)
Doc.SETTLEMENT_NO= RefNo$
Doc.FinFlag="Finish"
Call SESS.SetEnvironmentVar("ENV_SETT",Right$("00000" & Cstr(DefNo&) ,5))
Call uidoc.Refresh
Else
Exit Sub
End If
get_ex_rate
get_cv_local
set_flag
Dim answer2 As Integer
answer2% = Msgbox("Do you want to save this document?", 1, "Save")
If answer2 = 1 Then
Petro$= uidoc.FieldGetText("Park_Petro_Car")
Vehicle$= uidoc.FieldGetText("Vehicle_No")
Gifts$ = uidoc.FieldGetText("Gifts")
Gifts_Ent$ = uidoc.FieldGetText("Gifts_Ent")
Medical$ = uidoc.FieldGetText("Medical")
Medical_Fee$ = uidoc.FieldGetText("Medical_Fee")
Others$= uidoc.FieldGetText("Others")
OS$= uidoc.FieldGetText("Others_Specify")
Taxi$ = uidoc.FieldGetText("Taxi")
Taxi_Fee$ = uidoc.FieldGetText("Taxi_Fee")
If Petro$ <> "" And Vehicle$ = "" Then
Msgbox "Please enter Vehicle No" , 16, "Vehicle No"
Else
If Gifts$ <> "" And Gifts_Ent$ = "" Then
Msgbox "Please enter Guest/Co.Name" , 16, "Guest/Co.Name"
Else
If Medical$ <> "" And Medical_Fee$ = "" Then
Msgbox "Please enter Medical_Fee" , 16, "Medical_Fee"
Else
If Taxi$ <> "" And Taxi_Fee$ = "" Then
Msgbox "Please enter Taxi Fee" , 16, "Taxi Fee"
Else
If Others$ <> "" And OS$ = "" Then
Msgbox "Please enter Others(Specify)" , 16, "Others (Specify)"
End If
End If
End If
End If
End If
End If
If answer2 = 2 Then
continue=False
Exit Sub
End If
uidoc.Refresh
'uidoc.close
End Sub
答案 0 :(得分:2)
感谢您添加代码。
使用“If uidoc.IsNewDoc = True Then
”,您明确告诉代码仅在文档是新的时运行。
因此,要么添加适当的elseif分支,要么删除if本身并相应地修改验证,以便它适用于新的和修改过的文档。
答案 1 :(得分:2)
从你的第一个IF语句中删除Else,否则验证只运行一次,当IsNewDoc返回True时,一旦文档被保存,一旦它将返回False并且你的QuerySave子例程退出。
ELSE
退出Sub&lt; - 删除此项,您的验证码仅对每个文档运行一次
结束IF