Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EOF/BOF

Status
Not open for further replies.

sabavno

Programmer
Jul 25, 2002
381
CA
Hi

I use DAO and receice "NO CURRENT RECORD" error. I believe that is because I haven't taken care of EOF/BOF conditions.
What are the ways to treat EOF/BOF?

Thanks
 
Hi!

The standard way to check this is:

If rst.EOF = True and rst.BOF = True Then
etc

This will run the code if there are records in rst.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Hi

I am stuck with this BOF problem

Here is my code:

Public Sub Redeploy()

Dim lngPin As Long
Dim rst As DAO.Recordset
Dim sql As String


PIN_SerialNumber.SetFocus
lngPin = PIN_SerialNumber.Text

sql = "Select PIN_SerialNumber, AssetStatusID from BlackBerryRecord where PIN_SerialNumber = " & lngPin
Set rst = CurrentDb.OpenRecordset(sql, dbOpenDynaset)

If rst.NoMatch = False Then
If rst!AssetStatusID = 1 Then
MsgBox "There is an active record with the same PIN. Please enter another PIN"


PIN_SerialNumber = Null
blnOk = False

Else
rst.Edit
rst!AssetStatusID = 8
rst.Update
Set rst = Nothing
blnOk = True
End If
Else

Exit Sub
End If

End Sub


Well, when I run it and there is no match for PIN_SerialNumber, the rst.NoMatch = False...WHY? Shouldn't it be true?

And then it just gives me a error "NO CURRENT RECORD"

PLease help

Thanks
 
Hi!

The NoMatch test is only valid when you do a search of an open recordset like this:

rst.FindFirst Criteria

If rst.NoMatch = False

If you want to see if no records were returned then you use:

If rst.EOF = True and rst.BOF = True Then
etc.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top