I have this code: -

Code:
Dim MyConn As ADODB.Connection
Set MyConn = New ADODB.Connection
MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\database97.mdb;"
MyConn.Open
Set myrecset = MyConn.Execute("SELECT SUM(total) as total FROM calculations WHERE firstno = " & firstno.Text & " AND secondno = " & secondno.Text & " GROUP BY firstno, secondno")
If IsNull(myrecset.Fields.Item("total")) Then
calculate.Hide
incorrect.Show
MyConn.Close
Else
correct.total.Text = myrecset.Fields.Item("total")
calculate.Hide
correct.Show
MyConn.Close
End If
I am having a problem with the "If IsNull(myrecset.Fields.Item("total")) Then " and the else statement.

If IsNull(myrecset.Fields.Item("total")) Then
calculate.Hide
incorrect.Show
MyConn.Close

The above should hide the calculate form and show the incorrect form IF there is nothing in the database total field.

the else statement: -

Else
correct.total.Text = myrecset.Fields.Item("total")
calculate.Hide
correct.Show
MyConn.Close
End If

Puts the total in the database into 'total' text box and hides calculate form and shows the correct form.

When this is run and the 2 numbers match from the text boxes on calculate form (from the database query) then the correct (else) statement works.

But if you input 2 numbers which arent in the database and therefore have no total, then it displays:-

Run-time error '3021'

Either BOF or EOF is true or the current record has been deleted.

Requested operation requires a current record.

And highlights the else code: correct.total.Text = myrecset.Fields.Item("total")


Any idea whats wrong?