So you want to create a search form in continuous view, where the user can
select a record to view/edit in another form.
Build a form in tabular view that shows enough fields for the user to select
their record.
In the Form Header section, place some unbound boxes above the columns,
where the user can enter criteria to limit the search results. Add a command
button to read these boxes and create the WHERE clause for the form's
RecordSource. From there, opening the other form is just a matter of:
DoCmd.OpenForm "Form2", WhereCondition = "ClientID = " & Me.ClientID
Initially you can force the form to load with no record, by saving the
RecordSource as:
SELECT * FROM tblClient WHERE (False);
Below is the kind of thing that goes into the Click event of your cmdFilter
command button. It demonstrates the different delimiters for Text fields,
Date fields, and Number/Currency fields. It is constructed so it is very
easy to add as many more of these as you wish.
If you also wanted to let the user sort the form differently, that's just a
matter of changing the ORDER BY clause instead of using the constant.
----------code begins-----------
Private Sub cmdFilter_Click()
Dim strWhere As String
Dim lngLen As Long
Const strcStub = "SELECT tblClient.* FROM tblClient WHERE "
Const strcTail = " ORDER BY Surname, FirstName;"
'Filter a text field.
If Not IsNull(Me.txtFilterSurname) Then
strWhere = strWhere & "([Surname] = """ & Me.txtFilterSurname & """)
AND "
End If
'Filter a date field
If Not IsNull(Me.txtFilterDueDate) Then
strWhere = strWhere & ([DueDate] = #" & Format(Me.txtFilterDueDate,
"mm/dd/yyyy") & "#) AND "
End If
'Filter a Number field
If Not IsNull(Me.txtFilterAmount) Then
strWhere = strWhere & "([Amount] = " & Me.txtFilterAmount & ") AND "
End If
'etc for other fields.
lngLen = Len(strWhere) - 5 'Without trailing " AND ".
If lngLen <= 0 Then
MsgBox "No criteria"
Else
strWhere = Left$(strWhere, lngLen)
Me.RecordSource = strcStub & strWhere & strcTail
End If
End Sub
----------code ends-----------