急,贵求大侠帮助,帮我看看代码,老说FROM子句语法错误
'cmbField是combo1的
cmbName是combo2的
cmdadd是添加(command1)的
cmddel是删除(command2)的
cmdedit是修改(command3)的
cmdclear是清空(command4)的'
Private Sub cmbField_Click()
cmbName.Clear
Adodc1.RecordSource = "select * from 库存表"
Adodc1.Refresh
Do While Not Adodc1.Recordset.EOF
cmbName.AddItem Adodc1.Recordset.Fields(cmbField.Text)
Adodc1.Recordset.MoveNext
Loop
cmbName.Text = cmbName.List(0)
End Sub
Private Sub cmbName_Click()
Dim comdition
condition = Trim(cmbField.Text)
If Adodc1.Recordset.Fields(condition).Type = 202 Then
Adodc1.RecordSource = "select * from 库存表 where" & condition & " = '" & cmbName.Text & "'"
Else
Adodc1.RecordSource = "select * from 库存表 where" & condition & " = " & cmbName.Text
End If
Adodc1.Refresh
txtno.Text = Adodc1.Recordset.Fields("货物编号")
txtname.Text = Adodc1.Recordset.Fields("货物名称")
txtstorenum.Text = Adodc1.Recordset.Fields("库存量")
txtunit.Text = Adodc1.Recordset.Fields("单位")
txtstorekeeper.Text = Adodc1.Recordset.Fields("仓管人员")
txtbDate.Text = Adodc1.Recordset.Fields("进货日期")
txtprice.Text = Adodc1.Recordset.Fields("进货单价")
End Sub
Private Sub cmdAdd_Click(Index As Integer)
On Error GoTo errorhandler:
If txtno.Text <> "" Then
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("货物编号") = Val(txtno.Text)
Adodc1.Recordset.Fields("货物名称") = txtname.Text
Adodc1.Recordset.Fields("库存量") = Val(txtstorenum.Text)
Adodc1.Recordset.Fields("单位") = txtnuit.Text
Adodc1.Recordset.Fields("仓管人员") = txtstorekeeper.Text
Adodc1.Recordset.Fields("进货日期") = Val(txtbDate.Text)
Adodc1.Recordset.Fields("进货单价") = Val(txtprice.Text)
Adodc1.Recordset.Update
Adodc1.RecordSource = "select * from 库存表"
Adodc1.Refresh
Do While Not Adodc1.Recordset.EOF
cmbName.AddItem Adodc1.Recordset.Fields(1)
Adodc1.Recordset.MoveNext
Loop
cmbField_Click
cmbclear_Click
Else
MsgBox "货物编号是主索引字段,不能为空。", , "错误提示"
End If
Exit Sub
errorhandler: MsgBox "货物编号是主索引,不能重复", , "错误提示"
End Sub
Private Sub cmdclear_Click(Index As Integer)
txtno.Text = ""
txtname.Text = ""
txtstorenum.Text = ""
txtunit.Text = ""
txtstorekeeper.Text = ""
txtbDate.Text = ""
txtprice.Text = ""
End Sub
Private Sub cmddel_Click(Index As Integer)
If txtname.Text <> "" Then
Adodc1.RecordSource = "select * from 库存表 where 货物名称 ='" & txtname.Text & "'"
Adodc1.Refresh
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveNext
cmbName.Clear
cmbField_Click
cmbclear_Click
End If
End Sub
Private Sub cmdedit_Click(Index As Integer)
On Error GoTo errorhandler:
If txtno.Text <> "" Then
Adodc1.RecordSource = "select * from 库存表 where 货物编号 =" & txtno.Text
Adodc1.Refresh
Adodc1.Recordset.Fields("货物编号") = txtno.Text
Adodc1.Recordset.Fields("货物名称") = txtname.Text
Adodc1.Recordset.Fields("库存量") = txtstorenum.Text
Adodc1.Recordset.Fields("单位") = txtnuit.Text
Adodc1.Recordset.Fields("仓管人员") = txtstorekeeper.Text
Adodc1.Recordset.Fields("进货日期") = txtbDate.Text
Adodc1.Recordset.Fields("进货单价") = txtprice.Text
Else
MsgBox "货物编号是主索引字段,不能为空。", , "错误提示"
End If
Exit Sub
errorhandler: MsgBox "货物编号是主索引字段,不能重复", , "错误提示"
End Sub
Private Sub Form_Load()
Dim i As Integer
Adodc1.RecordSource = "select * from 库存表"
Adodc1.Refresh
cmbField.Clear
For i = 0 To Adodc1.Recordset.Fields.Count - 1
cmbField.AddItem Adodc1.Recordset.Fields(i).Name
Next i
cmbField.Text = cmbField.List(0)
End Sub