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