If pev=""And last=""then sql="select * from informains where chk='1' and id="&CInt(id) Else If pev<>""Then sql="select top 1 * from informains where chk='1' and id<"&CInt(pev) &" order by id desc" EndIf If last<>""Then sql="select top 1 * from informains where chk='1' and id>"&CInt(last) Endif EndIf