以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  在窗口中怎样限制明细表可添加的行数  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=153663)

--  作者:禾成
--  发布时间:2020/8/18 17:42:00
--  在窗口中怎样限制明细表可添加的行数
如题,有一窗口,左边是送货主表,右边是送货明细表,我想限制每一送货单最多只能添加10条明细,请问老师怎么做?

图片点击可在新窗口打开查看此主题相关图片如下:dd.png
图片点击可在新窗口打开查看


--  作者:有点蓝
--  发布时间:2020/8/18 20:13:00
--  
参考:http://www.foxtable.com/webhelp/topics/0629.htm,如:

If tables("主表").current is nothing orelse e.datatable.compute("counr(送货号)","送货号=\'" & tables("主表").current("送货号") & "\'")>= 10 Then 
    e.Cancel = True \'那么取消输入并提示用户
    Messagebox.Show(
"超10条!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End
 
If

--  作者:禾成
--  发布时间:2020/8/18 21:35:00
--  
我代码用在按钮上,按你上面的方法不好用,可以直接计算窗口表的行数吗?大约如下这样
但具体不会
Dim sl As Integer
sl = dataTables("送货_Table4").datarows.count
If sl>= 10 then
    Messagebox.Show("超10条!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
    Tables("送货主表.送货明细表").AddNew()
    Forms("送货选择").Open()
End If
[此贴子已经被作者于2020/8/18 21:36:46编辑过]

--  作者:有点蓝
--  发布时间:2020/8/18 21:41:00
--  
Dim sl As Integer
sl = Tables("送货主表.送货明细表").rows.count
If sl>= 10 then
    Messagebox.Show("超10条!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
    Tables("送货主表.送货明细表").AddNew()
    Forms("送货选择").Open()
End If

--  作者:禾成
--  发布时间:2020/8/18 21:50:00
--  
谢谢指点,又在data这里出错
--  作者:禾成
--  发布时间:2020/8/20 9:56:00
--  
在同一个窗口如下面这样写,如果在另一窗口呢?
Dim sl As Integer
sl = Tables("送货主表.送货明细表").rows.count
If sl>= 10 then
    Messagebox.Show("超10条!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
    Tables("送货主表.送货明细表").AddNew()
    Forms("送货选择").Open()
End If
我是这样的,却不行
Dim sl As Integer
sl = Forms("送货").????这里怎么写( Tables("送货主表.送货明细表").rows.count ) 


--  作者:有点蓝
--  发布时间:2020/8/20 10:05:00
--  
关联表不管放到哪个窗口的用法都一样Tables("送货主表.送货明细表")

如果是副本: Forms("送货").controls(“table1”).table.rows.count