7,763
社区成员
发帖
与我相关
我的任务
分享
Dim rs1 As ADODB.Recordset '定义一个记录集对象rs1
Set rs1 = New ADODB.Recordset
Dim rs2 As ADODB.Recordset '定义一个记录集对象rs1
Set rs2 = New ADODB.Recordset
Dim cnn1 As ADODB.Connection '定义一个连接对象cnn1
Set cnn1 = New ADODB.Connection
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\daoju.mdb;Persist Security Info=False"
Dim connter As Integer
Dim sql1 As String
Dim sql2 As String
Dim sql3 As String
Dim sql4 As String
Dim zhi As String
sql3 = "Select * From zuoye where 成品料号 = '" + Text1.Text + "' " '以成品料号查询其配置零件编码及其配置数量
Set rs1 = cnn1.Execute(sql3)
x = rs1("零件编码") '把上面查询到的成品料号配置零件编码设为变量X
y = rs1("零件配置数量") '把上面查询到的成品料号配置零件数量设为变量Y
Do While Not rs1.EOF
sql4 = "select * from chuwei where 零件编码 ='" & x & "' and 零件库存数量>='" & y & "'" '逐个查询每个零件库存数量大于该配置零件的数量
Set rs2 = cnn1.Execute(sql4) '*****这里要加rs2*****
If rs2.EOF = True Then 如发现有配置零件数量大于现有库存时
MsgBox ("领出数量大于可用数量!")
zhi = 1 '对上面的特殊情况做一个标示 赋个值
Exit Do
End If '*****加*****
rs1.MoveNext
Loop
rs1.MoveFirst '*****要移回开头*****
If zhi <> 1 Then 当不符合上面的特殊情况就执行下面的语句
Do While Not rs1.EOF
sql1 = "update chuwei set 零件库存数量 = 零件库存数量-'" & y & "' where bianma ='" & x & "' "
cnn1.Execute (sql1)
cnn1.Execute (sql2)
rs1.MoveNext
Loop
End If
cnn1.Close
Set cnn1 = Nothing
MsgBox ("信息保存成功!")
Dim rs1 As ADODB.Recordset '定义一个记录集对象rs1
Set rs1 = New ADODB.Recordset
Dim rs2 As ADODB.Recordset '定义一个记录集对象rs1
Set rs2 = New ADODB.Recordset
Dim cnn1 As ADODB.Connection '定义一个连接对象cnn1
Set cnn1 = New ADODB.Connection
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\daoju.mdb;Persist Security Info=False"
Dim connter As Integer
Dim sql1 As String
Dim sql2 As String
Dim sql3 As String
Dim sql4 As String
Dim zhi As String
sql3 = "Select * From zuoye where 成品料号 = '" + Text1.Text + "' " '以成品料号查询其配置零件编码及其配置数量
Set rs1 = cnn1.Execute(sql3)
x = rs1("零件编码") '把上面查询到的成品料号配置零件编码设为变量X
y = rs1("零件配置数量") '把上面查询到的成品料号配置零件数量设为变量Y
Do While Not rs1.EOF
sql4 = "select * from chuwei where 零件编码 ='" & x & "' and 零件库存数量>='" & y & "'" '逐个查询每个零件库存数量大于该配置零件的数量
Set rs2 = cnn1.Execute(sql4)
If rs2.EOF = True Then 如发现有配置零件数量大于现有库存时
MsgBox ("领出数量大于可用数量!")
zhi = 1 '对上面的特殊情况做一个标示 赋个值
Exit Do
End If
rs1.MoveNext
Loop
rs1.MoveFirst
If zhi <> 1 Then 当不符合上面的特殊情况就执行下面的语句
Do While Not rs1.EOF
sql1 = "update chuwei set 零件库存数量 = 零件库存数量-'" & y & "' where bianma ='" & x & "' "
cnn1.Execute (sql1)
cnn1.Execute (sql2)
rs1.MoveNext
Loop
End If
cnn1.Close
Set cnn1 = Nothing
MsgBox ("信息保存成功!")
Dim rs1 As ADODB.Recordset '定义一个记录集对象rs1
Set rs1 = New ADODB.Recordset
sql3 = "Select * From zuoye where 成品料号 = '" + Text1.Text + "' " '以成品料号查询其配置零件编码及其配置数量
Set rs1 = cnn1.Execute(sql3)
x = rs1("零件编码") '把上面查询到的成品料号配置零件编码设为变量X
y = rs1("零件配置数量") '把上面查询到的成品料号配置零件数量设为变量Y
Do While Not rs1.EOF
sql4 = "select * from chuwei where 零件编码 ='" & x & "' and 零件库存数量>='" & y & "'" '逐个查询每个零件库存数量大于该配置零件的数量
cnn1.Execute (sql4)
If rs1.EOF = True Then 如发现有配置零件数量大于现有库存时
MsgBox ("领出数量大于可用数量!")
zhi = 1 '对上面的特殊情况做一个标示 赋个值
Exit Do
End If '缺少
rs1.MoveNext
Loop
Close
If zhi <> 1 Then 当不符合上面的特殊情况就执行下面的语句
Do While Not rs1.EOF
sql1 = "update chuwei set 零件库存数量 = 零件库存数量-'" & y & "' where bianma ='" & x & "' "
cnn1.Execute (sql1)
cnn1.Execute (sql2)
rs1.MoveNext
Loop
End If
cnn1.Close
Set cnn1 = Nothing
MsgBox ("信息保存成功!")