
HELP - What Am I Doing Wrong
Try using Filter rather than Find:
Me.Data1.Recordset.Filter="Fname='" & strNameA & "' AND Lname='" & strNameB
& "'"
This will reduce the recordset to just those records matching the filter.
To test if NO records match, use EOF AND BOF:
IF Me.Data1.Recordset.EOF AND Me.Data1.Recordset.BOF Then
MSgbox "No Records Match"
Else
Msgbox Me.Data1.Recordset.RecordCount & " Records Found"
End If
Remember to take the filter off again when you are finished:
Me.Data1.Recordset.Filter=""
Quote:
> When you say "2 tables - 'Fname and Lname: I assume you mean
columns/fields
> and not tables.
> Actually you have a number of problems.
> Firstly, the problem is quotes and spaces!
> Correcting for that you would think this would work...
> With Me.Data1.Recordset
> .Find "Fname='" & strNameA & "' AND Lname='" & strNameB & "'"
> End With
> ...however, the Find method only allows ONE column to be specified, so
using
> Find you can only use Fname OR LName.
> RichardF
> --
> > I use Access 2000 db with 2 tables - 'Fname and Lname"
> > I need to search a record by first name and last name using ADO but
> also
> > need to have an error message pop up when the names are not found. I use
> the
> > code:
> > Private Sub cmdSearch_Click()
> > '
> > Dim strNameA as String
> > Dim strNameB as String
> > '
> > strNameA = InputBox("Enter first name:", "Find Participant")
> > If strNameA = "" Then
> > Exit Sub
> > End If
> > strNameB = InputBox("Enter last name:", "Find Participant")
> > If strNameB = "" Then
> > Exit Sub
> > End If
> > With Me.Data1.Recordset
> > .Find "Fname=" & strNameA & "Lname=" & strNameB
> > End With
> > '
> > End Sub
> > What Am I Doing Wrong?
> > Thanks
> > Jay