> I have created a recordset in ADO and would like to perform
> two different operations dependant on if the recordset
> contains one or greater than one record. However I
> seem only to receive the .Recordset value of -1,
> disregardless of how many records are contained in the
> cursor. How can I get around this?
> The code I am using is as follows.
> Thank you for any suggestions you might have.
> Kind Regards
> Sub displayStaffSurname(inSurname As String)
> On Error GoTo Err_displayStaffSurname
> 'Proceedure called from
> ' => Form: FrmPersonnel
> ' => CmdBtn: cmdSearch_Click()
> Dim cnn As ADODB.Connection
> Dim cmd As ADODB.Command
> Dim rst As ADODB.Recordset
> Set cnn = New ADODB.Connection
> Set cmd = New ADODB.Command
> Set rst = New ADODB.Recordset
> 'Open the connection
> Set cnn = CurrentProject.Connection
> 'Set up the Command objects's Connection, SQL and
> parameter types
> With cmd
> .ActiveConnection = cnn
> .CommandText = "SELECT * FROM tblStaff WHERE
> Surname = " & "'" & inSurname & "'"
> End With
> Set rst = cmd.Execute
> If rst.EOF Then
> MsgBox "No Matching Surname, Try Agan :-)",
> vbOKOnly, "Incorrect Entry"
> ElseIf (rst.RecordCount = 1) Then '**** PROBLEM HERE
> 'display singular record on Main Personnel Form
> Forms![frmPersonnel]!txtSurname = Trim(rst!Surname)
> Forms![frmPersonnel]!txtFirstName = Trim(rst!
> Forms![frmPersonnel]!txtDepot = Trim(rst!Depot)
> Forms![frmPersonnel]!txtDepartment = Trim(rst!
> ElseIf (rst.RecordCount > 1) Then '**** PROBLEM HERE
> 'loop through and populate fields on a different
> End If
> Set cmd = Nothing
> Exit Sub
> MsgBox Err.Description
> Resume Exit_displayStaffSurname
> End Sub