是这样,我的表单有的有表控件,有的没有.
原来这段代码我是遍历控件,判断table1控件是否存在?代码如下:
If e.Sender.Text = "保存单据" Then
If Tables(e.form.Name).Rows.Count>0 Then
Tables(e.form.Name).Current("修改人") = _UserName
Tables(e.form.Name).Current("修改时间") = Date.Now()
Tables(e.form.Name).DataTable.Save()
End If
For Each c As Winform.Control In e.Form.Controls
If Typeof c Is WinForm.Table Then
If e.form.ExistControl("Table1") =True Then
If DataTables(e.form.Name & "_Table1").DataRows.Count>0 Then
DataTables(e.form.Name & "_Table1").Save
End If
Dim t As Table = Tables(e.form.Name & "_Table1")
With Tables(e.form.Name)
If .Current Is Nothing Then
t.Filter = "False"
Else
t.Filter = "系统单号 = '" & .Current("系统单号") & "'"
End If
End With
End If
End If
Next
End If
但是提示,找不到Table1的控件.后来改成这样:
If e.Sender.Text = "保存单据" Then
If Tables(e.form.Name).Rows.Count>0 Then
Tables(e.form.Name).Current("修改人") = _UserName
Tables(e.form.Name).Current("修改时间") = Date.Now()
Tables(e.form.Name).DataTable.Save()
If e.form.ExistControl(e.form.Name & "_Table1") =True Then
If DataTables(e.form.Name & "_Table1").DataRows.Count>0 Then
DataTables(e.form.Name & "_Table1").Save
End If
Dim t As Table = Tables(e.form.Name & "_Table1")
With Tables(e.form.Name)
If .Current Is Nothing Then
t.Filter = "False"
Else
t.Filter = "系统单号 = '" & .Current("系统单号") & "'"
End If
End With
End If
End If
End If
这样是不提示了,但是窗口表不保存,是什么问题?