TrueStar
TrueStar

Reputation:

Handle empty recordset in Visual Basic 6

How can I handle the case when the following statement returns nothing, i.e. a non-existing record?

Form1.data1.RecordSource = "SELECT * " _
                         & "FROM Table " _
                         & "WHERE Column1 = " & txtSomeTextField.Text & ""
Form1.data1.Refresh

Edit: The error I get is: Run-time error '3021': No current record

Upvotes: 2

Views: 5361

Answers (1)

JP Alioto
JP Alioto

Reputation: 45117

Check for EOF And BOF of the record set ...

If Not rs.EOF And Not rs.BOF Then
   ' You have results
End If

Upvotes: 9

Related Questions