以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  加入代码后窗口控件都变成不可用状态  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=85962)

--  作者:scofields
--  发布时间:2016/6/6 21:35:00
--  加入代码后窗口控件都变成不可用状态
红袍老师,我在表属性AfterselChange加入以下代码,发现窗体控件变成不可用了,这可怎么改?
If Forms("销售计划录入2").Opened AndAlso e.NewRange.RowSel >= 0 Then
    Dim r As Row = e.Table.Rows(e.NewRange.RowSel)
If Tables("JHS").Current IsNot Nothing Then 
        Forms("销售计划录入2").Controls("ComboBox3").Enabled = False
        Forms("销售计划录入2").Controls("ComboBox1").Enabled = False
        Forms("销售计划录入2").Controls("ComboBox2").Enabled = False
        Forms("销售计划录入2").Controls("子客户").Enabled = False
        Forms("销售计划录入2").Controls("数量").Enabled = False
        Forms("销售计划录入2").Controls("textbox1").Enabled = False
    Else
        Forms("销售计划录入2").Controls("ComboBox3").Enabled = True
        Forms("销售计划录入2").Controls("ComboBox1").Enabled = True
        Forms("销售计划录入2").Controls("ComboBox2").Enabled = True
        Forms("销售计划录入2").Controls("子客户").Enabled = True
        Forms("销售计划录入2").Controls("数量").Enabled = True
        Forms("销售计划录入2").Controls("textbox1").Enabled = True
    End If
End If

--  作者:Hyphen
--  发布时间:2016/6/7 9:05:00
--  
代码想实现什么逻辑?

If Tables("JHS").Current IsNot Nothing Then 试试改成

If Tables("JHS").Current Is Nothing Then 

--  作者:scofields
--  发布时间:2016/6/7 15:20:00
--  
老师,我想实现所有行都不能进行二次修改,如果要修改,只有销售开票才可以修改(数据是通过窗体Textbox控件录入的)
--  作者:Hyphen
--  发布时间:2016/6/7 15:58:00
--  
If Forms("销售计划录入2").Opened AndAlso e.NewRange.RowSel >= 0 Then
    Dim r As Row = e.Table.Rows(e.NewRange.RowSel)
    If r.DataRow.RowState <> DataRowState.Added AndAlso r.DataRow("XXX列") <> "销售开票" Then
        Forms("销售计划录入2").Controls("ComboBox3").Enabled = False
        Forms("销售计划录入2").Controls("ComboBox1").Enabled = False
        Forms("销售计划录入2").Controls("ComboBox2").Enabled = False
        Forms("销售计划录入2").Controls("子客户").Enabled = False
        Forms("销售计划录入2").Controls("数量").Enabled = False
        Forms("销售计划录入2").Controls("textbox1").Enabled = False
    Else
        Forms("销售计划录入2").Controls("ComboBox3").Enabled = True
        Forms("销售计划录入2").Controls("ComboBox1").Enabled = True
        Forms("销售计划录入2").Controls("ComboBox2").Enabled = True
        Forms("销售计划录入2").Controls("子客户").Enabled = True
        Forms("销售计划录入2").Controls("数量").Enabled = True
        Forms("销售计划录入2").Controls("textbox1").Enabled = True
    End If
End If

--  作者:scofields
--  发布时间:2016/6/8 10:27:00
--  回复:(Hyphen)If Forms("销售计划录入2").Opened A...
老师,我把 r.DataRow("XXX列") <> "销售开票"去掉之后,发现代码无效,也不提示错误,我想实现所有记录一旦新增后,就不可以再通过窗口修改了,这又怎么改呢?
--  作者:大红袍
--  发布时间:2016/6/8 10:31:00
--  
 设置的代码,应该写到CurrentChanged事件去。
--  作者:scofields
--  发布时间:2016/6/8 15:25:00
--  回复:(大红袍) 设置的代码,应该写到CurrentC...
红袍老师,这段代码写到CurrentChanged之后出错了。我不知道怎么改啊?


--  作者:scofields
--  发布时间:2016/6/8 15:25:00
--  
If forms("窗口2").opened AndAlso e.NewRange.RowSel >= 0 Then
    Dim r As Row = e.Table.Rows(e.NewRange.RowSel)
    If r.DataRow.RowState <> DataRowState.Added Then
Forms("窗口2").controls("客户").Enabled = False
Forms("窗口2").controls("子客户").Enabled = False
Forms("窗口2").controls("品种").Enabled = False
Forms("窗口2").controls("包装").Enabled = False
Forms("窗口2").controls("车号1").Enabled = False
Forms("窗口2").controls("车号2").Enabled = False
Forms("窗口2").controls("车号3").Enabled = False
Forms("窗口2").controls("车号4").Enabled = False
Forms("窗口2").controls("车号5").Enabled = False
Forms("窗口2").controls("车号6").Enabled = False
Forms("窗口2").controls("车号7").Enabled = False
Forms("窗口2").controls("车号8").Enabled = False
Forms("窗口2").controls("车号9").Enabled = False
Forms("窗口2").controls("车号10").Enabled = False
         Else
Forms("窗口2").controls("客户").Enabled = True
Forms("窗口2").controls("子客户").Enabled = True
Forms("窗口2").controls("品种").Enabled = True
Forms("窗口2").controls("包装").Enabled = True
Forms("窗口2").controls("车号1").Enabled = True
Forms("窗口2").controls("车号2").Enabled = True
Forms("窗口2").controls("车号3").Enabled = True
Forms("窗口2").controls("车号4").Enabled = True
Forms("窗口2").controls("车号5").Enabled = True
Forms("窗口2").controls("车号6").Enabled = True
Forms("窗口2").controls("车号7").Enabled = True
Forms("窗口2").controls("车号8").Enabled = True
Forms("窗口2").controls("车号9").Enabled = True
Forms("窗口2").controls("车号10").Enabled = True
    End If
End If

图片点击可在新窗口打开查看此主题相关图片如下:currentchanged.png
图片点击可在新窗口打开查看
[此贴子已经被作者于2016/6/8 15:30:55编辑过]

--  作者:大红袍
--  发布时间:2016/6/8 19:19:00
--  
Dim r As Row = e.Table.current
If forms("窗口2").opened AndAlso r IsNot Nothing Then
    If r.DataRow.RowState <> DataRowState.Added Then
        Forms("窗口2").controls("客户").Enabled = False
        Forms("窗口2").controls("子客户").Enabled = False
        Forms("窗口2").controls("品种").Enabled = False
        Forms("窗口2").controls("包装").Enabled = False
        Forms("窗口2").controls("车号1").Enabled = False
        Forms("窗口2").controls("车号2").Enabled = False
        Forms("窗口2").controls("车号3").Enabled = False
        Forms("窗口2").controls("车号4").Enabled = False
        Forms("窗口2").controls("车号5").Enabled = False
        Forms("窗口2").controls("车号6").Enabled = False
        Forms("窗口2").controls("车号7").Enabled = False
        Forms("窗口2").controls("车号8").Enabled = False
        Forms("窗口2").controls("车号9").Enabled = False
        Forms("窗口2").controls("车号10").Enabled = False
    Else
        Forms("窗口2").controls("客户").Enabled = True
        Forms("窗口2").controls("子客户").Enabled = True
        Forms("窗口2").controls("品种").Enabled = True
        Forms("窗口2").controls("包装").Enabled = True
        Forms("窗口2").controls("车号1").Enabled = True
        Forms("窗口2").controls("车号2").Enabled = True
        Forms("窗口2").controls("车号3").Enabled = True
        Forms("窗口2").controls("车号4").Enabled = True
        Forms("窗口2").controls("车号5").Enabled = True
        Forms("窗口2").controls("车号6").Enabled = True
        Forms("窗口2").controls("车号7").Enabled = True
        Forms("窗口2").controls("车号8").Enabled = True
        Forms("窗口2").controls("车号9").Enabled = True
        Forms("窗口2").controls("车号10").Enabled = True
    End If
End If

--  作者:scofields
--  发布时间:2016/6/8 21:33:00
--  
红袍老师,为什么执行删除代码时会出现这个错误?愁死我了
图片点击可在新窗口打开查看此主题相关图片如下:qq图片20160608213203.png
图片点击可在新窗口打开查看