I have this code in an onclick event of a command button on a form. But I would also like the same code to run when the user presses the Enter key after making an entry in any field on the form. How can this be done?
Here is the onclick code of the command button.
Private Sub cmdSearchContracts_Click()
Dim strWhereCondition As String
'lots of code here (removed for this demonstration) to establish the strWhereCondition
If Right(strWhereCondition, 5) = " AND " Then strWhereCondition = Left(strWhereCondition, Len(strWhereCondition) - 5)
Me.Parent.subfrmSearchContractsDS.Form.Filter = strWhereCondition
Me.Parent.subfrmSearchContractsDS.Form.FilterOn = True
Me.Parent.subfrmSearchContractsDS.Form.Visible = True