代码
Dim Mrc As ADODB.Recordset
Dim txtSQL As String
Dim Msgtext As String
Private Sub Command1_Click()
If Not IsNumeric(Text1.Text) Then
MsgBox "编号输入有误!", vbOKOnly + vbExclamation, "错误"
Text1.SetFocus
Exit Sub
End If
If Text5.Text = "" Then
MsgBox "入库时间不可为空!", vbOKOnly + vbExclamation, "错误"
Exit Sub
Text5.SetFocus
End If
If Text2.Text = "" Then
MsgBox "产品名称不可为空!", vbOKOnly + vbExclamation, "错误"
Exit Sub
Text2.SetFocus
End If
If Text3.Text = "" Then
MsgBox "产品类型不可为空!", vbOKOnly + vbExclamation, "错误"
Exit Sub
Text3.SetFocus
End If
txtSQL = "delete from 库存报表 where 产品编号='" & Trim(Text1) & "'"
Set Mrc = ExecuteSQL(txtSQL, Msgtext)
txtSQL = "select * from 库存报表"
Set Mrc = ExecuteSQL(txtSQL, Msgtext)
Mrc.AddNew
Mrc.Fields(0) = Trim(Text1)
Mrc.Fields(1) = Trim(Text2)
Mrc.Fields(2) = Trim(Text3)
Mrc.Fields(3) = Trim(Text4)
Mrc.Fields(4) = Trim(Text5)
Mrc.Fields(5) = Trim(Text6)
Mrc.Fields(6) = Trim(Text7)
Mrc.Fields(7) = Trim(Text8)
Mrc.Update
Mrc.Close
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
MsgBox "信息修改成功!", vbOKOnly, "提示"
ShowData
End Sub
Private Sub ShowData()
Dim txSQL As String
Dim Mrcc As ADODB.Recordset
txSQL = "select * from 库存报表"
Set Mrcc = ExecuteSQL(txSQL, Msgtext)
With MSFlexGrid1
.ColWidth(0) = 1500
.ColWidth(1) = 2000
.ColWidth(2) = 1000
.ColWidth(3) = 2000
.ColWidth(4) = 1200
.ColWidth(5) = 1500
.ColWidth(6) = 1500
.ColWidth(7) = 2000
.TextMatrix(0, 0) = "产品编号"
.TextMatrix(0, 1) = "产品名称"
.TextMatrix(0, 2) = "产品类型"
.TextMatrix(0, 3) = "供应商名称"
.TextMatrix(0, 4) = "入库时间"
.TextMatrix(0, 5) = "入库价格"
.TextMatrix(0, 6) = "入库数量"
.TextMatrix(0, 7) = "产品简介"
.Rows = 1
Do While Not Mrcc.EOF
.Rows = .Rows + 1
For i = 0 To Mrcc.Fields.Count - 1
.TextMatrix(.Rows - 1, i) = Mrcc.Fields(i) & ""
Next i
Mrcc.MoveNext
Loop
End With
Mrcc.Close
End SubPrivate Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
End SubPrivate Sub Command3_Click()
txtSQL = "delete from 库存报表 where 产品编号='" & Trim(Text1) & "'"
Set Mrc = ExecuteSQL(txtSQL, Msgtext)
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
MsgBox "基本信息已经删除!", vbOKOnly, "警告"
ShowData
End SubPrivate Sub Form_Load()
ShowData
End SubPrivate Sub MSFlexGrid1_Click()
Text1 = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 0))
Text2 = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 1))
Text3 = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 2))
Text4 = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 3))
Text5 = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 4))
Text6 = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 5))
Text7 = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 6))
Text8 = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 7))
End Sub
错误在 Mrc.Update 这句
Dim Mrc As ADODB.Recordset
Dim txtSQL As String
Dim Msgtext As String
Private Sub Command1_Click()
If Not IsNumeric(Text1.Text) Then
MsgBox "编号输入有误!", vbOKOnly + vbExclamation, "错误"
Text1.SetFocus
Exit Sub
End If
If Text5.Text = "" Then
MsgBox "入库时间不可为空!", vbOKOnly + vbExclamation, "错误"
Exit Sub
Text5.SetFocus
End If
If Text2.Text = "" Then
MsgBox "产品名称不可为空!", vbOKOnly + vbExclamation, "错误"
Exit Sub
Text2.SetFocus
End If
If Text3.Text = "" Then
MsgBox "产品类型不可为空!", vbOKOnly + vbExclamation, "错误"
Exit Sub
Text3.SetFocus
End If
txtSQL = "delete from 库存报表 where 产品编号='" & Trim(Text1) & "'"
Set Mrc = ExecuteSQL(txtSQL, Msgtext)
txtSQL = "select * from 库存报表"
Set Mrc = ExecuteSQL(txtSQL, Msgtext)
Mrc.AddNew
Mrc.Fields(0) = Trim(Text1)
Mrc.Fields(1) = Trim(Text2)
Mrc.Fields(2) = Trim(Text3)
Mrc.Fields(3) = Trim(Text4)
Mrc.Fields(4) = Trim(Text5)
Mrc.Fields(5) = Trim(Text6)
Mrc.Fields(6) = Trim(Text7)
Mrc.Fields(7) = Trim(Text8)
Mrc.Update
Mrc.Close
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
MsgBox "信息修改成功!", vbOKOnly, "提示"
ShowData
End Sub
Private Sub ShowData()
Dim txSQL As String
Dim Mrcc As ADODB.Recordset
txSQL = "select * from 库存报表"
Set Mrcc = ExecuteSQL(txSQL, Msgtext)
With MSFlexGrid1
.ColWidth(0) = 1500
.ColWidth(1) = 2000
.ColWidth(2) = 1000
.ColWidth(3) = 2000
.ColWidth(4) = 1200
.ColWidth(5) = 1500
.ColWidth(6) = 1500
.ColWidth(7) = 2000
.TextMatrix(0, 0) = "产品编号"
.TextMatrix(0, 1) = "产品名称"
.TextMatrix(0, 2) = "产品类型"
.TextMatrix(0, 3) = "供应商名称"
.TextMatrix(0, 4) = "入库时间"
.TextMatrix(0, 5) = "入库价格"
.TextMatrix(0, 6) = "入库数量"
.TextMatrix(0, 7) = "产品简介"
.Rows = 1
Do While Not Mrcc.EOF
.Rows = .Rows + 1
For i = 0 To Mrcc.Fields.Count - 1
.TextMatrix(.Rows - 1, i) = Mrcc.Fields(i) & ""
Next i
Mrcc.MoveNext
Loop
End With
Mrcc.Close
End SubPrivate Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
End SubPrivate Sub Command3_Click()
txtSQL = "delete from 库存报表 where 产品编号='" & Trim(Text1) & "'"
Set Mrc = ExecuteSQL(txtSQL, Msgtext)
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
MsgBox "基本信息已经删除!", vbOKOnly, "警告"
ShowData
End SubPrivate Sub Form_Load()
ShowData
End SubPrivate Sub MSFlexGrid1_Click()
Text1 = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 0))
Text2 = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 1))
Text3 = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 2))
Text4 = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 3))
Text5 = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 4))
Text6 = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 5))
Text7 = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 6))
Text8 = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 7))
End Sub
错误在 Mrc.Update 这句
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货