高手帮我看看这段代码那有错误
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim str1 As String
Dim str2 As String
Dim str3 As String
Dim str4 As String
Private Sub Command1_Click()
' txtnull
suo (False)
DataGrid1.Enabled = False
Command1.Enabled = False
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = False
End Sub
Private Sub Command2_Click()
Adodc1.Refresh
End Sub
Private Sub Command3_Click()
Dim cn As New ADODB.Connection
If funnull = False Then
str4 = "insert into 交易(衣服编号,衣服颜色,衣服样式,送衣时间,取衣时间,洗衣单价,洗衣方式,顾客姓名)&values( '" & Trim(Text1) & "','" & Trim(Text2) & "','" & Trim(Text3) & "','" & Trim(Text4) & "','" & Trim(Text5) & "','" & Trim(Text6) & "','" & Trim(Text7) & "','" & Trim(Text8) & "')"
cn.ConnectionString = conn
cn.Open
cn.Execute str4
Command3.Enabled = False
Command4.Enabled = False
DataGrid1.Enabled = True
Command1.Enabled = True
Command5.Enabled = True
cn.Close
Set cn = Nothing
End If
Form_Load
End Sub
Private Sub Command4_Click()
DataGrid1.Enabled = True
Command1.Enabled = True
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = True
End Sub
Private Sub Command5_Click()
End
End Sub
Private Sub DataGrid1_Click()
str2 = "select * from 交易"
On Error Resume Next
cnn.ConnectionString = conn
cnn.Open
Set rst.ActiveConnection = cnn
rst.Open str2
If Not rst.EOF Then
With Adodc1.Recordset
Text1.Text = .Fields("衣服编号")
Text2.Text = .Fields("衣服颜色")
Text3.Text = .Fields("衣服样式")
Text4.Text = .Fields("送衣时间")
Text5.Text = .Fields("取衣时间")
Text6.Text = .Fields("洗衣单价")
Text7.Text = .Fields("洗衣方式")
Text8.Text = .Fields("顾客姓名")
End With
End If
rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
End Sub
Private Sub Form_Load()
suo (True)
Command3.Enabled = False
Command4.Enabled = False
str1 = "select * from 交易"
Adodc1.ConnectionString = conn
Adodc1.RecordSource = str1
Set DataGrid1.DataSource = Adodc1
DataGrid1.Columns(0).Visible = False
DataGrid1.AllowAddNew = False
DataGrid1.AllowUpdate = False
'Adodc1.Refresh
DataGrid1.Refresh
End Sub
Private Sub suo(bshow As Boolean)
Text1.Locked = bshow
Text2.Locked = bshow
Text3.Locked = bshow
Text4.Locked = bshow
Text5.Locked = bshow
Text6.Locked = bshow
Text7.Locked = bshow
Text8.Locked = bshow
End Sub
Private Function funnull() As Boolean
If Trim(Text1) = "" Then
MsgBox "衣服编号不可以为空!", 64, "提示"
funnull = True
Text1.SetFocus
Exit Function
End If
If Trim(Text2) = "" Then
MsgBox "衣服颜色不可以为空!", 64, "提示"
funnull = True
Text2.SetFocus
Exit Function
End If
If Trim(Text3) = "" Then
MsgBox "衣服样式不可以为空!", 64, "提示"
funnull = True
Text3.SetFocus
Exit Function
End If
If Trim(Text4) = "" Then
MsgBox "送衣时间不可以为空!", 64, "提示"
funnull = True
Text4.SetFocus
Exit Function
End If
If Trim(Text5) = "" Then
MsgBox "取衣服时间不可以为空!", 64, "提示"
funnull = True
Text5.SetFocus
Exit Function
End If
If Trim(Text6) = "" Then
MsgBox "洗衣价格不可以为空!", 64, "提示"
Text6.SetFocus
funnull = True
Exit Function
End If
If Trim(Text7) = "" Then
MsgBox "洗衣方式不可以为空!", 64, "提示"
Text7.SetFocus
funnull = True
Exit Function
End If
If Trim(Text8) = "" Then
MsgBox "顾客姓名不可以为空!", 64, "提示"
Text8.SetFocus
funnull
Exit Function
End If
End Function
Private Sub txtnull()
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
Text6 = ""
Text7 = ""
Text8 = ""
End Sub