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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

no current record

Status
Not open for further replies.

matrixindicator

IS-IT--Management
Sep 6, 2007
418
BE
Code:
strSQLClose = "SELECT T3A_TODO.refIDRQ, T3A_TODO.TaskYN, Count(T3A_TODO.TaskTitle) AS CountTaskTitle " _
& "FROM T3A_TODO " _
& "GROUP BY T3A_TODO.refIDRQ, T3A_TODO.TaskYN " _
& "HAVING (((T3A_TODO.refIDRQ)= " & strForm & " AND ((T3A_TODO.TaskYN)=Yes)));"

Set rst = dbs.OpenRecordset(strSQLClose, dbOpenDynaset)
If rst.BOF > 0 Then
intCountTasksClose = rst!CountTasktitle
Else
intCountTasksClose = 0
End If

How to say if there is not a record count, found for the condition set a 0, else show the numbers that match the condition. Now he is generating the error message "no current record".
 
Change this
Code:
If rst.BOF > 0 Then
to this
Code:
If NOT rst.BOF Then
BOF is a Boolean that returns TRUE (-1) or FALSE (0). It will never be > 0.
 

you probably want to add

Code:
If not rst.BOF Then
 rst.movelast
 intCountTasksClose = rst!CountTasktitle
Else
 intCountTasksClose = 0
End If

the reason for the move last is that it forves the recordset tp be counted in full - otherwise you can get incorrect answers on larger or slower data sets.

SeeThru
Synergy Connections Ltd - Telemarketing Services

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top