以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]排序锁定  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=77753)

--  作者:表哥
--  发布时间:2015/11/24 17:00:00
--  [求助]排序锁定
如何能把表中数据排序后锁定,使得从新打开项目后仍然按设定顺序排序。
--  作者:大红袍
--  发布时间:2015/11/24 17:06:00
--  

执行这段代码

 

For Each r As Row In Tables("表a").Rows
    r.DataRow.baserow("_Sortkey") = r.Index
Next

 

Tables("表a").Save


--  作者:表哥
--  发布时间:2015/11/24 17:09:00
--  
写在表的afterlood事件中吗?
--  作者:大红袍
--  发布时间:2015/11/24 17:21:00
--  

排序锁定的代码后面

 

For Each r As Row In Tables("表a").Rows
    If r.Locked = True Then
        r.locked = False
        r.DataRow.baserow("_Sortkey") = r.Index
        r.locked = True
    Else
        r.DataRow.baserow("_Sortkey") = r.Index
    End If
Next

 

Tables("表a").Save