1,217
社区成员
发帖
与我相关
我的任务
分享
Option Compare Database
Option Explict
Public Function GetRS(ByVal strQuery As String) As ADODB.Recordset
Dim rs As New ADODB.Resordset
Dim conn As New ADODB.Connection
On Error GoTo GetRS_Error
Set conn = CurrentProject.Connection
rs.Open strQuery, conn, adOpenKeyset, adLockOptimistic
Set GetRS = rs
GetRS_Exit:
Set rs = Nothing
Set conn = Nothing
Exit Function
GetRS_Error:
MsgBox (Err.Description)
Resume GetRS_Exit
End Function
Public Sub ExecuteSQL(ByVal strCmd As String)
Dim conn As New ADODB.Connection
On Error GoTo ExecuteSQL_Error
Set conn = CurrentProject.Connection
conn.Execute Trim$(strCmd)
ExecuteSQL_Exit:
Set conn = Nothing
Exit Sub
ExecuteSQL_Error:
MsgBox (Err.Description)
Resume ExecuteSQL_Exit
End Sub