这段代码为什么会提示:3709错误,要求的对象记录关闭或打开?Dim RST1 As New ADODB.Recordset
Dim SQL As String
Private Sub ListBox2_Click()
frmsalequery.TextBox5.Text = ListBox2.List(ListBox2.ListIndex, 1) & ListBox2.List(ListBox2.ListIndex, 2)
proselect.Hide
End Sub
Private Sub UserForm_Initialize()
Call mydovro<--------RST,CNN的设置在这儿!
SQL = "select distinct cprb from cpda"
RST.Open SQL, CNN, adOpenKeyset
ListBox1.Font.Size = 11
ListBox2.Font.Size = 11
ListBox2.ColumnWidths = "1;145"
Do While Not RST.EOF
ListBox1.AddItem RST!cprb
RST.MoveNext
Loop
End Sub
Private Sub Listbox1_Click()
SQL = "select distinct cpmc,cpgg from cpda where cprb='" & ListBox1 & "'"
RST1.Open SQL, CNN, adOpenKeyset<------------问题出在这儿
ListBox2.ColumnCount = 3
ListBox2.Clear
RR = 0
Do While Not RST1.EOF
ListBox2.AddItem
ListBox2.List(RR, 1) = RST1!cpmc
ListBox2.List(RR, 2) = RST1!cpgg
RST1.MoveNext
RR = RR + 1
Loop
End SubPrivate Sub UserForm_Terminate()
Set RST1 = Nothing: Set RST = Nothing: Set CNN = Nothing
End Sub
应该是关闭记录集,写的位子不对,大家帮我看看!谢谢!
Dim SQL As String
Private Sub ListBox2_Click()
frmsalequery.TextBox5.Text = ListBox2.List(ListBox2.ListIndex, 1) & ListBox2.List(ListBox2.ListIndex, 2)
proselect.Hide
End Sub
Private Sub UserForm_Initialize()
Call mydovro<--------RST,CNN的设置在这儿!
SQL = "select distinct cprb from cpda"
RST.Open SQL, CNN, adOpenKeyset
ListBox1.Font.Size = 11
ListBox2.Font.Size = 11
ListBox2.ColumnWidths = "1;145"
Do While Not RST.EOF
ListBox1.AddItem RST!cprb
RST.MoveNext
Loop
End Sub
Private Sub Listbox1_Click()
SQL = "select distinct cpmc,cpgg from cpda where cprb='" & ListBox1 & "'"
RST1.Open SQL, CNN, adOpenKeyset<------------问题出在这儿
ListBox2.ColumnCount = 3
ListBox2.Clear
RR = 0
Do While Not RST1.EOF
ListBox2.AddItem
ListBox2.List(RR, 1) = RST1!cpmc
ListBox2.List(RR, 2) = RST1!cpgg
RST1.MoveNext
RR = RR + 1
Loop
End SubPrivate Sub UserForm_Terminate()
Set RST1 = Nothing: Set RST = Nothing: Set CNN = Nothing
End Sub
应该是关闭记录集,写的位子不对,大家帮我看看!谢谢!
Call mydovro<--------RST,CNN的设置在这儿!
SQL = "select distinct cprb from cpda"
RST.Open SQL, CNN, adOpenKeyset
ListBox1.Font.Size = 11
ListBox2.Font.Size = 11
ListBox2.ColumnWidths = "1;145"
Do While Not RST.EOF
ListBox1.AddItem RST!cprb
RST.MoveNext
Loop
加:set RST=nothing
End Sub
Call mydovro
SQL = "select distinct cpmc,cpgg from cpda where cprb='" & ListBox1 & "'"
RST1.Open SQL, CNN, adOpenKeyset<------------问题出在这儿
ListBox2.ColumnCount = 3
ListBox2.Clear
RR = 0
Do While Not RST1.EOF
ListBox2.AddItem
ListBox2.List(RR, 1) = RST1!cpmc
ListBox2.List(RR, 2) = RST1!cpgg
RST1.MoveNext
RR = RR + 1
Loop
End Sub