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

Record is out of range??

Status
Not open for further replies.

Holm78

Programmer
Mar 5, 2002
60
SE
Hello

When I sort my grid with varios buttons with set filter().
But if the filter don't find any records an error comes up:

record is out of range.

Here is the code for one button:

clear
thisform.label3.caption = "ATT GÖRA IDAG"
set filter to avslutad <> .T. and startdatum = (date())
thisform.grid1.refresh
thisform.grid1.setfocus
go top
LOCAL lnCount

lnRecNo = RECN()
COUNT FOR (avslutad) <> .T. and (startdatum) = date() ;
AND !DELETED() TO lnCount
GO lnRecNo

THISFORM.label4.Caption = ALLT(STR(lnCount))

Is it maybe the count function that causes the problem??
Need help.
Thanks
//Holm
 
Change it to this:

clear
thisform.label3.caption = &quot;ATT GÖRA IDAG&quot;
select (thisform.grid1.recordsource)
set filter to avslutad <> .T. and startdatum = (date())
thisform.grid1.refresh
thisform.grid1.setfocus
select (thisform.grid1.recordsource)
if !bof() and !eof()
go top

LOCAL lnCount

lnRecNo = RECN()
COUNT FOR (avslutad) <> .T. and (startdatum) = date() ;
AND !DELETED() TO lnCount
GO lnRecNo

THISFORM.label4.Caption = ALLT(STR(lnCount))
else
THISFORM.label4.Caption = '0'
endif



Charl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top