Article ID: 139047
Article Last Modified on 10/11/2006
Option Explicit
Public Function FormFindRecord(IdValue As Variant) As Boolean
On Local Error GoTo FormFindRecord_Err
Me.SetFocus
' Set focus to OrderId control for lookup.
Me!OrderID.Enabled = True
DoCmd.GoToControl "OrderID"
DoCmd.FindRecord IdValue, , True, , True
DoEvents
If Me!OrderID = IdValue Then
FormFindRecord = True
End If
FormFindRecord_End:
DoCmd.GoToControl "CustomerID"
Me!OrderID.Enabled = False
Exit Function
FormFindRecord_Err:
MsgBox Error$
Resume FormFindRecord_End
End Function
NOTE: The design of the Orders form disables the OrderID control
so it cannot be edited. The above method is consistent with the
form's design by not allowing the OrderID control to be edited. By
encapsulating this rule in the function, you limit the visibility of
this rule to the function itself and the caller of the function never
needs to be concerned with this restriction.
? FORM_Orders.FormFindRecord(10400)
Keywords: kbhowto kbprogramming kbusage KB139047