根据不同的SQL语句获取记录集 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) '对记录集的相关操作…… …… RS.Close Set RS=Nothing |
|站长邮箱|小黑屋|手机版|Office中国/Access中国
( 粤ICP备10043721号-1 )
GMT+8, 2025-4-2 12:53 , Processed in 0.066110 second(s), 16 queries .
Powered by Discuz! X3.3
© 2001-2017 Comsenz Inc.