Results 1 to 6 of 6
  1. #1
    WHerman is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    4

    Run time 2101 error when changing tabs on 2 out of 3 pc

    I have an application installed on three user pc's. Two of the PC receive 2101 errors when changing tabs to pull transaction history, one machine does not. I can not duplicate the error on my development machine. All of us are using MS Access 2010 my version did match the version of the pc's getting the 2101 error. All three pc's are current with microsoft office updates and access updates. All are running the same version of the access software. I am using a subform and have tried importing the sub form from a old version of the application before the error started and replacing the current version. This did not fix the 2101 error on the two pc's. I have included a code snippet of where the error is occuring. The error occurs at the statement Me.subTransHistoryReview.LinkChildFields="Fund_Id" . I am looking for suggestions on what to try next to find the issue.
    Code:
    Case Is = 4
                If Me.Dirty = True Then
                    DoCmd.RunCommand acCmdSaveRecord
                End If
                'Me.Refresh
                If Me.subTransHistoryReview.SourceObject = "" Then
                    Me.subTransHistoryReview.SourceObject = "fsubTransHistoryReview_Fund"
                    Me.subTransHistoryReview.LinkChildFields = "Fund_Id"
                    Me.subTransHistoryReview.LinkMasterFields = "Fund_Id"
                    Me.subTransHistoryReview.Form.Requery
                End If


  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I would start by replacing the SourceObject *after* setting the LinkChild/masterFields properties. I'm also pretty sure setting the SourceObject causes a requery so the Requery line is probably unnecessary.

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Where are you using this code, i.e. in what event for what control?

    Is there a field named "Fund_ID" in the record source for the subform?

    It could also be a timing issue. Try putting DoEvents immediately following the line where you change the SourceObject.

  4. #4
    WHerman is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    4
    Hello RuralGuy tried your suggestion on development machine. This produced a 2101 error so changed code back to original.

    Hello John G There is a field named "Fund_ID" in the record source for the Subform. I have included the the code for the entire subroutine below. Basically on the main form a Fund_ID is selected from a drop down and on the Details Tab. The other tabs from left to right after the Details Tab are Main Address, Current transactions, Current Batch transactions, Transaction History and Accounts.

    Code:
    Private Sub TabCtl0_Change()
        Me.Application.Echo False
        Select Case Me.TabCtl0.Value
            Case Is = 1
                If Me.Dirty = True Then
                    DoCmd.RunCommand acCmdSaveRecord
                End If
                If bNewRecord = True Then
                    DoCmd.Hourglass True
                    DoCmd.SetWarnings False
    '                If DCount("Fund_Id", "Addresses", "Fund_Id = '" & Me.Fund_Id & "'") > 0 Then
    '                    DoCmd.RunSQL ("INSERT INTO Addresses SET Fund_Id = '" & Me.Fund_Id & "'")
    '                End If
                    iAddressId = DLookup("Address_Id", "Addresses", "Fund_Id = '" & Me.Fund_Id & "'")
                    Me.Address_Id.Requery
                    Me.Address_Id = iAddressId
                    bNewRecord = False
                    Me.subAddress.Form.Title1.SetFocus
                    DoCmd.SetWarnings True
                    DoCmd.Hourglass False
                End If
            Case Is = 4
                If Me.Dirty = True Then
                    DoCmd.RunCommand acCmdSaveRecord
                End If
                'Me.Refresh
                If Me.subTransHistoryReview.SourceObject = "" Then
                    Me.subTransHistoryReview.SourceObject = "fsubTransHistoryReview_Fund"
                    Me.subTransHistoryReview.LinkChildFields = "Fund_Id"
                    Me.subTransHistoryReview.LinkMasterFields = "Fund_Id"
                    Me.subTransHistoryReview.Form.Requery
                End If
            Case Is = 5
                If Me.Dirty = True Then
                    DoCmd.RunCommand acCmdSaveRecord
                End If
                If Me.subAccounts.SourceObject = "" Then
                    Me.subAccounts.SourceObject = "fsubAccounts"
                    Me.subAccounts.LinkChildFields = "Fund_Id"
                    Me.subAccounts.LinkMasterFields = "Fund_Id"
                End If
                Me.subAccounts.Form.Requery
        End Select
        Me.Application.Echo True
    
    End Sub

  5. #5
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Why are you changing the SourceObject of the subform at all? You always use the same subform (fsubTransHistoryReview_Fund), and the selection made in the main form combo box doesn't change anything. (The same is also true for the fsubAccounts.)

    Now, if the subforms you use do change depending on the selection made in the combo box, I'd suggest you make the changes in the After Update event of the combo box, and fix the code so that it specifies different sub-forms depending on the selection.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I'm pretty sure the OP has left the SourceObject blank to speed up the form. The test is to see if it is a ZLS. I use the Change event of the TabControl often but I don't change the SourceObject much.

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

Similar Threads

  1. Replies: 3
    Last Post: 01-06-2016, 03:48 PM
  2. Replies: 3
    Last Post: 01-23-2014, 07:49 AM
  3. Run-time error '2101'
    By amd711 in forum Programming
    Replies: 3
    Last Post: 11-18-2012, 04:46 AM
  4. Replies: 0
    Last Post: 07-16-2012, 05:42 AM
  5. Subform Change - Run-time error 2101
    By Cheshire101 in forum Forms
    Replies: 3
    Last Post: 12-21-2009, 12:37 PM

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