以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  表事件如何停止窗口代码执行  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=102162)

--  作者:whyxd
--  发布时间:2017/6/14 11:49:00
--  表事件如何停止窗口代码执行
在表A的BeforeSaveDataRow 事件中的代码:
Dim frm As WinForm.Form = Forms.ActiveForm
If frm IsNot Nothing Then
    If frm.Name = "客户" Then
        Dim count2 As Integer = DataTables("item").compute("count([id])","[number] Is null And [name] is null and [region] is null")
        If count2 > 0 Then
            DataTables("item").DeleteFor("[number] Is null And [name] is null and [MnemonicCode] is null")
        End If
        Dim count As Integer =DataTables("item").Compute("count([ID])","[number] Is null or [name] is null or [region] is null" )
        If count > 0 Then
            e.Cancel = True
            msgbox("客户信息内容输入不完整!""*""为必填项!")
            Return
        End If
    End If
End If
在"客户"窗口中,按钮“save”代码:
Tables("item").Current.Save

问题:如果客户信息内容不完整(count > 0),如何能使按钮“save”中代码“Tables("item").Current.Save”不执行?

--  作者:有点色
--  发布时间:2017/6/14 12:02:00
--  

首先,执行了 e.Cancel 之后,就是不保存的。

 

 

如果你需要得到信息,就用变量

 

表事件

 

vars("能保存") = False  \'或者true

 

save按钮

 

Tables("item").Current.Save

If vars("能保存") = true Then

    msgbox("保存了")

Else

    msgbox("没保存")

End If


--  作者:whyxd
--  发布时间:2017/6/14 12:41:00
--  回复:(有点色)首先,执行了 e.Cancel 之后,就是不...
不好意思,色老师,我表达有误,是这个意思:
save按钮(保存并退出)的代码:
\'保存当前行
Tables("item").Current.Save
\'关闭当前窗口
Dim frm As WinForm.Form = Forms.ActiveForm
If frm IsNot Nothing Then
    frm.close
End If
取消保存后,怎么能停止执行关闭窗口的代码

--  作者:有点色
--  发布时间:2017/6/14 14:23:00
--  

表事件,对应的赋值

 

vars("能保存") = False  \'或者true

 

save按钮

 

Tables("item").Current.Save

If vars("能保存") = true Then

    msgbox("保存了,执行关闭代码")

Else

    msgbox("没保存,不需要写代码")

End If


--  作者:whyxd
--  发布时间:2017/6/15 9:55:00
--  回复:(有点色)表事件,对应的赋值 vars("...
明白了,多谢图片点击可在新窗口打开查看