以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  DropDownForm 有DropTable属性,其它 的模式或独立 窗口有这样的属性吗?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=93661)

--  作者:yancheng
--  发布时间:2016/12/3 16:47:00
--  DropDownForm 有DropTable属性,其它 的模式或独立 窗口有这样的属性吗?
 If e.Form.DropTable IsNot Nothing Then \'如果下拉窗口是从表中打开
        tr = e.Form.DropTable.Current \'获取此表的当前行
    Else \'如果下拉窗口是通过DropdownBox打开
        Dim nm As String = e.Form.DropDownBox.BindingField \'获取绑定的字段
        nm = nm.Split(".")(0) \'获取绑定的表名
        tr = Tables(nm).Current \'获取此表的当前行


我现在有一个:模式窗口:添加 供应商;
双击事件如下:

Dim str() As String = {"材料维护","采购订单维护","预算计划维护","机具订单维护","采购入库维护","收支维护"}
Dim str1() As String = {"材料","采购订单","预算计划","机具订单","采购入库","收支管理"}
For i As Integer = 0 To str.Length-1
    If Forms(str(i)).opened Then
        Dim tbl As Table = Tables("添加供应商_Table1")
        Dim dr As Row = Tables(str1(i)).Current
        If dr IsNot Nothing  Then
            If Tables(str1(i)).Cols.Contains("供应商编号") Then
                dr("供应商编号") = tbl.Current("供应商编号")
            ElseIf Tables(str1(i)).Cols.Contains("单位编号") Then
                dr("单位编号") = tbl.Current("供应商编号")
                dr("往来单位") = tbl.Current("公司名称")
            End If
            e.Form.Close()
            Return
        End If
    End If
Next

如果 能判断,是哪一个表或者TextBox,触发它弹出的,就不用写FOR EACH 遍历了。


[此贴子已经被作者于2016/12/3 16:51:57编辑过]

--  作者:有点蓝
--  发布时间:2016/12/3 17:06:00
--  
只有DropDownForm 有DropTable属性

打开模式窗口前用全局变量指定需要接收数据的表名称就好了

vars("表") = "材料"
Forms("添加供应商").open

双击事件
Dim tbl As Table = Tables("添加供应商_Table1")
Dim dr As Row = Tables(vars("表")).Current
        If dr IsNot Nothing  Then
            If Tables(vars("表")).Cols.Contains("供应商编号") Then
                dr("供应商编号") = tbl.Current("供应商编号")
            ElseIf Tables(vars("表")).Cols.Contains("单位编号") Then
                dr("单位编号") = tbl.Current("供应商编号")
                dr("往来单位") = tbl.Current("公司名称")
            End If
            e.Form.Close()
        End If