Dim arstStores(1 To 3) As ADODB.Recordset
Dim intLoop As Integer
Dim strSQL As String
Dim strCnn As String
Dim strMessage As String
Dim strFind As String
' 将记录集作为静态游标类型记录集打开。
Set arstStores(1) = New ADODB.Recordset
arstStores(1).CursorType = adOpenStatic
arstStores(1).LockType = adLockBatchOptimistic
arstStores(1).Open strSQL, strCnn, , , adCmdText
' 创建原 Recordset 的两个副本。
Set arstStores(2) = arstStores(1).Clone
Set arstStores(3) = arstStores(1).Clone
Do While True
' 在数组中循环以使用户每一遍都搜索相同 Recordset 的不同副本。
For intLoop = 1 To 3
' 要求在显示每个 Recordset 当前记录集指针位置时搜索字符串。
strMessage = _
"Recordsets from stores table:" & vbCr & _
" 1 - Original - Record pointer at " & _
arstStores(1)!stor_name & vbCr & _
" 2 - Clone - Record pointer at " & _
arstStores(2)!stor_name & vbCr & _
" 3 - Clone - Record pointer at " & _
arstStores(3)!stor_name & vbCr & _
"Enter search string for #" & intLoop & ":"
strFind = Trim(InputBox(strMessage))
If strFind = "" Then Exit Do
' 查找搜索字符串,如果没有匹配的,请跳转到最后的记录。
arstStores(intLoop).Filter = "stor_name >= '" & strFind & "'"
If arstStores(intLoop).EOF Then
arstStores(intLoop).Filter = adFilterNone
arstStores(intLoop).MoveLast
End If
Dim intcmb As Integer
Dim rsClone As ADODB.Recordset
Set rsClone = AdoAccount.Recordset.Clone 'clone
Combo1.Clear
For intcmb = 1 To rsClone.RecordCount
If rsClone("account") & "" <> "" Then
Combo1.AddItem rsClone("account"), intcmb - 1
End If
rsClone.MoveNext
Next intcmb
Set rsClone = Nothing