修改ACCESS数据的求助
本人写了一段小代码,运行时出现"错误3705","打开对象时不允许操作"的错误,请大侠们帮助解决,十分感谢!在线等!!!Option Explicit
Dim rs1 As New ADODB.Recordset, rs2 As New ADODB.Recordset '定义数据集对象
Dim cnn As New ADODB.Connection '定义数据连接
Dim i As Integer '定义整型变量
Dim blnAdd As Boolean
Dim myval As Long
Private Sub Command1_Click()
rs2.Open "select * from 清单 where ID='" & Text1.Text & "'", cnn, adOpenKeyset, adLockOptimistic
rs2.Fields("特征A1") = Combo1.Text
rs2.Fields("特征B1") = Combo2.Text
rs2.Fields("特征C1") = Combo3.Text
rs2.Fields("特征D1") = Combo4.Text
rs2.Fields("特征E1") = Combo5.Text
rs2.Fields("特征F1") = Combo6.Text
rs2.Fields("特征G1") = Combo7.Text
rs2.Fields("特征H1") = Combo8.Text
rs2.Fields("特征I1") = Combo9.Text
rs2.Fields("特征J1") = Combo10.Text
rs2.Update
rs2.Close
Unload Me
End Sub
Private Sub Form_Load() '数据库连接
Text1.Text = 清单查询.Text1.Text
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=清单库.mdb;Persist Security Info=False"
rs1.Open "清单 order by ID='" & Text1.Text & "'", cnn, adLockOptimistic
'rs1.Refresh
Text2.Text = rs1.Fields("项目名称")
Text3.Text = rs1.Fields("单位")
If rs1.Fields("特征A") <> "" Then
Label1.Caption = rs1.Fields("特征A")
Else
Label1.Caption = ""
Combo1.Visible = False
'Label4.Caption = ""
End If
If rs1.Fields("特征B") <> "" Then
Label2.Caption = rs1.Fields("特征B")
Else
Label2.Caption = ""
Combo2.Visible = False
'Label15.Caption = ""
End If
If rs1.Fields("特征C") <> "" Then
Label3.Caption = rs1.Fields("特征C")
Else
Label3.Caption = ""
Combo3.Visible = False
'Label18.Caption = ""
End If
If rs1.Fields("特征D") <> "" Then
Label4.Caption = rs1.Fields("特征D")
Else
Label4.Caption = ""
Combo4.Visible = False
'Label19.Caption = ""
End If
If rs1.Fields("特征E") <> "" Then
Label5.Caption = rs1.Fields("特征E")
Else
Label5.Caption = ""
Combo5.Visible = False
'Label20.Caption = ""
End If
If rs1.Fields("特征F") <> "" Then
Label6.Caption = rs1.Fields("特征F")
Else
Label6.Caption = ""
Combo6.Visible = False
'Label21.Caption = ""
End If
If rs1.Fields("特征G") <> "" Then
Label7.Caption = rs1.Fields("特征G")
Else
Label7.Caption = ""
Combo7.Visible = False
'Label22.Caption = ""
End If
If rs1.Fields("特征H") <> "" Then
Label8.Caption = rs1.Fields("特征H")
Else
Label8.Caption = ""
Combo8.Visible = False
'Label23.Caption = ""
End If
If rs1.Fields("特征I") <> "" Then
Label9.Caption = rs1.Fields("特征I")
Else
Label9.Caption = ""
Combo9.Visible = False
'Label24.Caption = ""
End If
If rs1.Fields("特征J") <> "" Then
Label10.Caption = rs1.Fields("特征J")
Else
Label10.Caption = ""
Combo10.Visible = False
'Label25.Caption = ""
End If
For i = 1 To 10
If rs1.Fields("特征A" & i) <> "" Then
Combo1.AddItem rs1.Fields("特征A" & i).Value
End If
If rs1.Fields("特征B" & i) <> "" Then
Combo2.AddItem rs1.Fields("特征B" & i).Value
End If
If rs1.Fields("特征C" & i) <> "" Then
Combo3.AddItem rs1.Fields("特征C" & i).Value
End If
If rs1.Fields("特征D" & i) <> "" Then
Combo4.AddItem rs1.Fields("特征D" & i).Value
End If
If rs1.Fields("特征E" & i) <> "" Then
Combo5.AddItem rs1.Fields("特征E" & i).Value
End If
If rs1.Fields("特征F" & i) <> "" Then
Combo6.AddItem rs1.Fields("特征F" & i).Value
End If
If rs1.Fields("特征G" & i) <> "" Then
Combo7.AddItem rs1.Fields("特征G" & i).Value
End If
If rs1.Fields("特征H" & i) <> "" Then
Combo8.AddItem rs1.Fields("特征H" & i).Value
End If
If rs1.Fields("特征I" & i) <> "" Then
Combo9.AddItem rs1.Fields("特征I" & i).Value
End If
If rs1.Fields("特征J" & i) <> "" Then
Combo10.AddItem rs1.Fields("特征J" & i).Value
End If
Next i
'Unload Me
End Sub