如何解决此错误“错误3001:参数无效”

时间:2019-04-28 19:13:25

标签: ms-access access-vba

我在访问VBA时遇到此问题,它不断给我错误3001:无效的参数。我是这种语言的新手,找不到网上的错误或其他任何解决方案。

我真的很乐意提供帮助。

我尝试使用DAO,但它给我“与现有模块的NAme冲突...”错误

      Public Function AuditChanges(RecordID As String, UserAction As String)
On Error GoTo auditerr

Dim DB As Database
Dim rst As Recordset
Dim clt As Control
Dim UserLogin As String

Set DB = CurrentDb
Set rst = DB.OpenRecordset("select * from tbl_TRACKMP", adOpenDynamic)

UserLogin = Environ("UserName")
Select Case UserAction
    Case "new"
        With rst
            .AddNew
            ![DateTime] = Now()
            !UserName = UserLogin
            !FormName = Screen.ActiveForm.Name
            !Action = UserAction
            !RecordID = Screen.ActiveForm.Controls(RecordID).Value
            .Update

         End With

    Case "Delete"
        With rst
            .AddNew
            ![DateTime] = Now()
            !UserName = UserLogin
            !FormName = Screen.ActiveForm.Name
            !Action = UserAction
            !RecordID = Screen.ActiveForm.Controls(RecordID).Value
            .Update

        End With

    Case "Edit"
        For Each clt In Screen.ActiveForm.Controls
            If (clt.ControlType = acTextBox _
                Or clt.ControlType = acComboBox) Then
                If Nz(clt.Value) <> Nz(clt.OldValue) Then
                With rst
                    .AddNew
                    ![DateTime] = Now()
                    !UserName = UserLogin
                    !FormName = Screen.ActiveForm.Name
                    !Action = UserAction
                    !RecordID = Screen.ActiveForm.Controls(RecordID).Value
                    !FieldName = clt.ControlSource
                    !OldValue = clt.OldValue
                    !newvalue = clt.Value
                    .Update
                End With
            End If
        End If

    Next clt

End Select

rst.Close
DB.Close
Set rst = Nothing
Set DB = Nothing
auditerr:
MsgBox Err.Number & " : " & Err.Description, vbCritical, "Error"
Exit Function

End Function

0 个答案:

没有答案