执行不了模块,F8分步执行才能执行到,是怎么回事啊。。。
Private Sub cmddelete_Click()Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path & "\ERPData.mdb " '数据库连接
conn.Open
rs.CursorLocation = adUseClient
rs.Open "select * from tf_scll where tf_scll.领料单号='" & Text_id & "'", conn, adOpenStatic, adLockOptimistic
YN = MsgBox("确定删除", vbYesNo)
If YN = 6 Then
rs.Delete
End If
zld_refresh (Text_zld)
生产领料.Text_id = ""
生产领料.Text_date = ""
生产领料.Dept = ""
生产领料.Text_zld = ""
生产领料.Grid1.Clear
Call Form_Load
生产领料.cmdAdd.Enabled = True
生产领料.cmddelete.Enabled = flase
生产领料.cmdUpdate.Enabled = flase
生产领料.Cmdedit.Enabled = flase
生产领料.cmdCancel.Enabled = flase
End Sub
这是窗体的一个过程
zld_refresh (Text_zld)执行不了,但是设置断点后按F8就能执行到模块里。
我的基础知识不好,VB是边用边自学,求各位老师指点,莫见笑。
下面是模块代码
Public Sub zld_refresh(ByVal zld_number As String)
Dim conn As ADODB.Connection
Dim Recordset As ADODB.Recordset
Dim Recordset1 As ADODB.Recordset
Dim Recordset2 As ADODB.Recordset
Set conn = New ADODB.Connection
Set Recordset = New ADODB.Recordset
Set Recordset1 = New ADODB.Recordset
Set Recordset2 = New ADODB.Recordset
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path & "\ERPData.mdb "
conn.Open
Recordset.CursorLocation = adUseClient
Recordset1.CursorLocation = adUseClient
Recordset2.CursorLocation = adUseClient
Recordset.Open "select * from mf_zld where mf_zld.制令单号='" & zld_number & "'", conn, adOpenStatic, adLockOptimistic
Recordset1.Open "select * from mf_scll where mf_scll.转入单号='" & zld_number & "'", conn, adOpenStatic, adLockOptimistic
Recordset2.Open "select * from mf_sctl where mf_sctl.转入单号='" & zld_number & "'", conn, adOpenStatic, adLockOptimistic
Recordset.MoveFirst
Do While Not Recordset.EOF
Recordset("已发量") = 0
If Recordset1.RecordCount <> 0 Then
Recordset1.MoveFirst
Do While Not Recordset1.EOF
If Recordset1("物料编码") = Recordset("物料编码") Then
Recordset("已发量") = Recordset("已发量") + IIf(IsNull(Recordset1("领料数量")), 0, Recordset1("领料数量"))
Recordset.Update
End If
Recordset1.MoveNext
Loop
End If
If Recordset2.RecordCount <> 0 Then
Recordset2.MoveFirst
Do While Not Recordset2.EOF
If Recordset2("物料编码") = Recordset("物料编码") Then
Recordset("已发量") = Recordset("已发量") - IIf(IsNull(Recordset1("退料数量")), 0, Recordset1("退料数量"))
Recordset.Update
End If
Recordset2.MoveNext
Loop
End If
If Recordset("应发量") - IIf(IsNull(Recordset("已发量")), 0, Recordset("已发量")) > 0 Or Recordset("已发量") = 0 Then
Recordset("未发量") = Recordset("应发量") - Recordset("已发量")
Recordset.Update
Else
Recordset("未发量") = 0
Recordset.Update
End If
Recordset.MoveNext
Loop
End Sub
各位老师谁能告诉我原因,我琢磨1个多小时了,快疯掉了。。。