Results 1 to 7 of 7
  1. #1
    jtm013 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Aug 2014
    Posts
    117

    Error 2475

    Hello,



    I have a form which records tool information. I set up a basic audit trail for this form using the information provided here: http://www.fontstuff.com/access/acctut21.htm

    My code for the module ended up looking very similar:

    Code:
    Sub AuditChanges(IDField As String)    On Error GoTo AuditChanges_Err
        Dim cnn As ADODB.Connection
        Dim rst As ADODB.Recordset
        Dim ctl As Control
        Dim datTimeCheck As Date
        Dim strUserID As String
        Dim strCompID As String
        Set cnn = CurrentProject.Connection
        Set rst = New ADODB.Recordset
        rst.Open "SELECT * FROM tblAuditTrail", cnn, adOpenDynamic, adLockOptimistic
        datTimeCheck = Now()
        strUserID = Environ("USERNAME")
        strCompID = Environ("ComputerName")
        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
                        ![ComputerName] = strCompID
                        ![FormName] = Screen.ActiveForm.Name
                        ![recordID] = Screen.ActiveForm.Controls(IDField).Value
                        ![FieldName] = ctl.ControlSource
                        ![OldValue] = ctl.OldValue
                        ![NewValue] = ctl.Value
                        .Update
                    End With
                End If
            End If
        Next ctl
    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
    I have the tags set up, and am calling the procedure from the before update event on the form in question.
    It had been working, but recently started throwing a Run-Time Error 2475. When I go to debug, the bolded/underlined section of code above is highlighted. Any and all help is appreciated. Thank you!
    Last edited by jtm013; 04-08-2015 at 07:11 AM. Reason: I cannot type.

  2. #2
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    what is the description for runtime error 2467?

  3. #3
    jtm013 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Aug 2014
    Posts
    117
    Apologies, I cannot type this morning it is actually error 2475 the description is: "You entered an expression that requires a form to be the active window."

  4. #4
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    OK - well that is telling you that there is no form in the active window - so you have moved the focus somewhere else - are you running this on a subform to your form for example?

  5. #5
    jtm013 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Aug 2014
    Posts
    117
    Quote Originally Posted by Ajax View Post
    OK - well that is telling you that there is no form in the active window - so you have moved the focus somewhere else - are you running this on a subform to your form for example?
    Yes there are two subforms.
    However, I have been using this DB for several months now and this has never happened before yesterday.

  6. #6
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    well, something has changed!

    I would step through your code starting with the first line of your before update event and in the intermediate window type

    ?Screen.ActiveForm.name

    after each line has executed until you find where the form is no longer active

  7. #7
    jtm013 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Aug 2014
    Posts
    117
    Solved- Turns out my coworker had changed some of the references. Once I restored the appropriate references, everything is now working.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 03-13-2015, 09:11 AM
  2. Replies: 3
    Last Post: 01-23-2014, 07:49 AM
  3. Error 2467
    By Ray67 in forum Forms
    Replies: 1
    Last Post: 01-26-2013, 11:41 PM
  4. Runtime 2467 only on a Win 7 Machine
    By ilikebirds in forum Forms
    Replies: 3
    Last Post: 12-11-2012, 03:58 PM
  5. Replies: 0
    Last Post: 07-16-2012, 05:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums