I'm using a form with a subform in datasheet view to show a set of contracts.
A button on the main form opens a Customers form for the currently selected company in the subform.
The Customers form has this On Load procedure
This works properly. Still in the Customer form I'd then like to be able to select and go to another customer's record. If I try to turn off the filter in the search combo's AfterUpdate event the record for the first Customer opens, not the one selected one's.
But doing the customer selection a second time works properly. How can I avoid this extra step?
A button on the main form opens a Customers form for the currently selected company in the subform.
Code:
Private Sub cmdShowContract_Click()
Dim SelectedID As Long
SelectedID = Me.sfmLedger.Form!CustomerID
'Open the customer form and pass the ID to the .OpenArgs
DoCmd.OpenForm "frmContracts", acNormal, , , acFormPropertySettings, acWindowNormal, SelectedID
End Sub
The Customers form has this On Load procedure
Code:
Private Sub Form_Load()
With Me
If Not IsNull(.OpenArgs) Then
.Filter = "[CustomerID]=" & .OpenArgs
.FilterOn = True
End If
End With
End Sub
This works properly. Still in the Customer form I'd then like to be able to select and go to another customer's record. If I try to turn off the filter in the search combo's AfterUpdate event the record for the first Customer opens, not the one selected one's.
Code:
Private Sub Combo10_AfterUpdate()
On Error GoTo Combo10_AfterUpdate_Err
If Me.FilterOn = True Then
Me.FilterOn = False
End If
DoCmd.SearchForRecord , "", acFirst, "[CustomerID] = " & Str(Nz(Screen.ActiveControl, 0))
Combo10_AfterUpdate_Exit:
Exit Sub
Combo10_AfterUpdate_Err:
MsgBox Error$
Resume Combo10_AfterUpdate_Exit
End Sub
But doing the customer selection a second time works properly. How can I avoid this extra step?