Foxtable(狐表)用户栏目专家坐堂 → [求助]数据填充的问题?


  共有9288人关注过本帖树形打印复制链接

主题:[求助]数据填充的问题?

帅哥哟,离线,有人找我吗?
lsf5138
  1楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:242 积分:2235 威望:0 精华:0 注册:2011/8/16 22:33:00
[求助]数据填充的问题?  发帖心情 Post By:2012/11/5 8:13:00 [只看该作者]

铵钮代码如下:

If _UserGroup = "物流部" Then
    With Tables("水洗")
        If .Current IsNot Nothing Then
            If Tables("水洗").Current("确认")=False   
                With e.Form
                    If .Controls("Label5").Text = "OK" Then  '如果信息完善,则新建令号
                        Dim Filter As String
                        With e.Form.Controls("TextBox4")
                            If .Value IsNot Nothing Then
                                Filter = "生产条码 = '" & .Value & "'"
                            End If
                        End With
                        If Filter > "" Then
                            Tables("织机生产").Filter = Filter
                        End If

                            With Tables("织机生产")
                                If .Current IsNot Nothing Then

                                    Dim tr As Row = Tables("织机生产").Current()
                                    tr("水洗批次") = .Controls("TextBox1").Value
                                    tr("水洗_载货日期") = .Controls("DateTimePicker2").Value
                                    tr("水洗_单位") = .Controls("ComboBox1").Value
                                    tr.Save()

                                Else
                                    MessageBox.show("没有这条记录!")
                                End If
                            End With

                    End If
                End With
            Else
                MessageBox.show("本批次已确认完成,不可再添加!")
            End If
        Else
            MessageBox.show("目录表没有记录!")
        End If
    End With
Else
    MessageBox.show("物流部才能操作!")
End If

原代码筛选后记录如果为空,再执行数据填充会报错。我就在筛选后加个记录为空不执行的代码,不知为什么加不了,会报错!


 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2012/11/5 8:25:00 [只看该作者]

别用那么多的With,你把自己给With糊涂了,只有连续使用的时候,用With比较合适,而且嵌套的With,生效的只是最里头一个。

 

If _UserGroup = "物流部" Then
    With Tables("水洗")
        If .Current IsNot Nothing Then
            If Tables("水洗").Current("确认")=False
                    If e.Form.Controls("Label5").Text = "OK" Then  '如果信息完善,则新建令号
                        Dim Filter As String
                        With e.Form.Controls("TextBox4")
                            If .Value IsNot Nothing Then
                                Filter = "生产条码 = '" & .Value & "'"
                            End If
                        End With
                        If Filter > "" Then
                            Tables("织机生产").Filter = Filter
                        End If
                        With Tables("织机生产")
                            If .Current IsNot Nothing Then
                               
                                Dim tr As Row = Tables("织机生产").Current()
                                tr("水洗批次") = e.Form.Controls("TextBox1").Value
                                tr("水洗_载货日期") = e.Form.Controls("DateTimePicker2").Value
                                tr("水洗_单位") = e.Form.Controls("ComboBox1").Value
                                tr.Save()
                            Else
                                MessageBox.show("没有这条记录!")
                            End If
                        End With
                    End If
            Else
                MessageBox.show("本批次已确认完成,不可再添加!")
            End If
        Else
            MessageBox.show("目录表没有记录!")
        End If
    End With
Else
    MessageBox.show("物流部才能操作!")
End If

 


 回到顶部