Compile Error Help (1 Viewer)

xyba

Registered User.
Local time
Today, 14:15
Joined
Jan 28, 2016
Messages
189
Not my day today!

I'm getting a "Compile Error: User Defined Type Not Defined" error in a module when debug/compiling and the debugger is highlighting the line in red. It worked fine until today so I'm wondering what could cause it.


The code is:
Code:
Sub AuditChanges(IDField As String, UserAction As String)
    On Error GoTo AuditChanges_Err
[COLOR="Red"]    Dim cnn As ADODB.Connection[/COLOR]
    Dim rst As ADODB.Recordset
    Dim ctl As Control
    Dim datTimeCheck As Date
    Dim strUserID As String
    Set cnn = CurrentProject.Connection
    Set rst = New ADODB.Recordset
    rst.Open "SELECT * FROM tblAuditTrail", cnn, adOpenDynamic, adLockOptimistic
    datTimeCheck = Now()
    strUserID = Environ("USERNAME")
    Select Case UserAction
        Case "EDIT"
            For Each ctl In Screen.ActiveForm.Controls
                If ctl.Tag = "Audit" Then
                    If Nz(ctl.Value) <> Nz(ctl.OldValue) Then
                        With rst
                            .AddNew
                            ![DateTime] = datTimeCheck
                            ![UserName] = strUserID
                            ![FormName] = Screen.ActiveForm.Name
                            ![Action] = UserAction
                            ![AuditRecordID] = Screen.ActiveForm.Controls(IDField).Value
                            ![FieldName] = ctl.ControlSource
                            ![OldValue] = ctl.OldValue
                            ![NewValue] = ctl.Value
                            .Update
                        End With
                    End If
                End If
            Next ctl
        Case Else
            With rst
                .AddNew
                ![DateTime] = datTimeCheck
                ![UserName] = strUserID
                ![FormName] = Screen.ActiveForm.Name
                ![Action] = UserAction
                ![AuditRecordID] = Screen.ActiveForm.Controls(IDField).Value
                .Update
            End With
    End Select
AuditChanges_Exit:
    On Error Resume Next
    rst.Close
    cnn.Close
    Set rst = Nothing
    Set cnn = Nothing
    Exit Sub
AuditChanges_Err:
    MsgBox Err.Description, vbCritical, "ERROR!"
    Resume AuditChanges_Exit
End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:15
Joined
Oct 29, 2018
Messages
21,358
Hi. Check your references and make sure you have a reference to ADO (Microsoft ActiveX Data Objects x.x. Library).
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:15
Joined
Aug 30, 2003
Messages
36,118
Do you have the ActiveX Data Objects reference checked?
 

xyba

Registered User.
Local time
Today, 14:15
Joined
Jan 28, 2016
Messages
189
Thanks both.

I did have Microsoft ActiveX Data Objects 6.1 Library checked but it had mysteriously been unchecked.

It must have been the latest Microsoft Windows update that caused it as I've had lots of issues (non-Access related too) today, after updating last night.

Thanks again.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:15
Joined
Oct 29, 2018
Messages
21,358
Thanks both.

I did have Microsoft ActiveX Data Objects 6.1 Library checked but it had mysteriously been unchecked.

It must have been the latest Microsoft Windows update that caused it as I've had lots of issues (non-Access related too) today, after updating last night.

Thanks again.
Hi. You're welcome. Paul and I were happy to assist. Good luck with your project.
 

Users who are viewing this thread

Top Bottom