
The simplest solution would be to use a combo box, whose RowSource is a query which returns all cheque numbers from the relevant table, as the control in the search form. That way you can guarantee that the cheque exists. The code for the combo box’s AfterUpdate event procedure would be like this:
Dim strCriteria As String
strCriteria = “CheckNr =" & Me.ActiveControl
If Not IsNull(Me.ActiveControl) Then
DoCmd.OpenForm "CDfrmchecksort", WhereCondition:=strCriteria
DoCmd.Close acForm, Me.Name
End If
The above assumes that the CheckNr column is of a number data type. If it’s of text data type amend the code as follows:
strCriteria = "CheckNr = """ & Me.ActiveControl & """"