根據(jù)不同的SQL語(yǔ)句獲取記錄集 Public Function GetRS(ByVal strQuery As String) As ADODB.Recordset Dim RS As New ADODB.Recordset Dim conn As New ADODB.Connection On Error GoTo GetRS_Error Set conn = CurrentProject.Connection RS.Open Trim$(strQuery), conn, adOpenKeyset, adLockOptimistic Set GetRS = RS GetRS_Exit: RS.Close Set RS = Nothing conn.Close Set conn = Nothing Exit Function GetRS_Error: MsgBox (Err.Description) Resume GetRS_Exit End Function '用法示例: Dim RS As New ADODB.Recordset Dim str As String str = "select * from 員工表" Set RS = GetRS(str) '對(duì)記錄集的相關(guān)操作…… …… RS.Close Set RS=Nothing |
|站長(zhǎng)郵箱|小黑屋|手機(jī)版|Office中國(guó)/Access中國(guó)
( 粵ICP備10043721號(hào)-1 )
GMT+8, 2025-7-13 07:59 , Processed in 0.059875 second(s), 16 queries .
Powered by Discuz! X3.3
© 2001-2017 Comsenz Inc.