count results from filter

B

benb

I have form that is used to search the database for a particular record. For
robust results, the form actually opens another form, displaying all the
records that matched the criteria with some additional identifying
information. The user can then double click on the record they choose, and a
third form opens, displaying the entire record for editing. What I wan to do
is adapt the code so that if there is only one entry matching the criteria,
the code will skip the intermediary form and open the single matching record
directly. I think this would be possible with the right if/then criteria
before the DoCmd.OpenForm. The code I have is something like this:

subject = Forms!frm_Search!txtSubject.Text
category = Forms!frm_Search!cmbCategory.Text
If Not IsNull(DLookup("[ID]", table, category & " Like " & Chr$(34)
& "*" & subject & "*" & Chr$(34) & " AND [Active] = -1")) Then
DoCmd.OpenForm FormName:="frm_Browse", view:=acNormal,
wherecondition:= category & " Like " & Chr$(34) & "*" & subject & "*" &
Chr$(34) & " AND [Active] = -1"
Else
GoTo no_results
End If
.................................
Private Sub Active_DblClick(Cancel As Integer)
Dim identifier As Long
If IsNull(Me.ID) = True Then
Exit Sub
End If
identifier = Me.ID
open_entry (identifier)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top