以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  DataFormat事件  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=158714)

--  作者:qazlinle6
--  发布时间:2020/11/30 12:18:00
--  DataFormat事件

DataFormat事件


Dim Filter As String
With e.Form.Controls("TextBox1")
    If .Value IsNot Nothing Then
        Filter = "电话 = \'" & .Value & "\'"
    End If
End With
If Filter > "" Then
    DataTables("会员资料").LoadFilter = Filter
DataTables("会员资料").Load
End If

如果没加载到内容就増加一行关联表

--  作者:有点蓝
--  发布时间:2020/11/30 13:35:00
--  
if DataTables("会员资料").datarows.count = 0 then
Tables("某关联表").addnew
end if

--  作者:qazlinle6
--  发布时间:2020/11/30 14:45:00
--  
Dim str As String = e.Sender.text
Dim reg As new System.Text.RegularExpressions.Regex("((\\d{11})|^((\\d{7,8})|(\\d{4}|\\d{3})-(\\d{7,8})|(\\d{4}|\\d{3})-(\\d{7,8})-(\\d{4}|\\d{3}|\\d{2}|\\d{1})|(\\d{7,8})-(\\d{4}|\\d{3}|\\d{2}|\\d{1}))$)")
If reg.Ismatch(str) = False Then
    msgbox("号码有误")
    e.cancel = True
End If

如果号码有误  If DataTables("会员资料").datarows.count = 0,,不执行下面这个代码

If DataTables("会员资料").datarows.count = 0 Then
  Dim dr As Row = Tables("会员资料").addnew    \'加到对应表
  dr("电话")=e.form.controls("TextBox1").text 
  dr("注册日期")=e.form.controls("TextBox2").text 
  dr("注册店名账号")=e.form.controls("TextBox3").text     \'表对应ComboBox4\'
  dr("注册店名")=e.form.controls("TextBox4").text     \'表对应ComboBox4\'
End If

--  作者:有点蓝
--  发布时间:2020/11/30 14:51:00
--  
是指不需要执行下面这个代码,还是指下面这个代码无法执行?
--  作者:qazlinle6
--  发布时间:2020/11/30 14:54:00
--  
号码错了不执行,号码对了还是要执行
--  作者:有点蓝
--  发布时间:2020/11/30 14:55:00
--  
If reg.Ismatch(str) = False Then
    msgbox("号码有误")
    e.cancel = True
return
End If

--  作者:qazlinle6
--  发布时间:2020/11/30 15:00:00
--  
我看下
[此贴子已经被作者于2020/11/30 15:00:44编辑过]