[AccessD] Show only X number records at a time

dmcafee at pacbell.net dmcafee at pacbell.net
Fri May 6 11:41:02 CDT 2005


here's one way it is done  with ASP.NEt & SQL Server:
http://www.codeproject.com/aspnet/dbpaging.asp


I take it you are trying to display some certain amount of records on an
unbound form? Remember access works differently that SQL server, and brings
over all records to the client side.

I would create a two variables, intMaxPageID and intPageNo (I guess you
could also have a intTotalPages)

Open the recordset, if DAO move last the first, get total count.
If count is greater than allowable per page, calculate MaxPages as such:
intMaxPages = rs.RecordCount / Max allowable

create a temp table and insert these records into the temp table. Make sure
the temp table has an autonumber PKID.

Now Select TOP whatever from the temp table as such:
(we'll use 100)

SELECT TOP 100 tmpPKID, CustName, CustID, CustTotals
FROM tblTempTable
WHERE tmpPKID >intMaxPageID and <=(intMaxPageID +100)


Move last and store the last records PKID in intMaxPageID

IF you want to calculate the current page number, you can create a function:

Function GetCurrentPageNo (intMaxPageID) AS integer
IF intMaxPageID Mod 100 = 0  or intMaxPageID Mod 100 >49 THEN
	GetCurrentPageNo = Cint(intMaxPageID /100)
Else intMaxPageID Mod 100 < 50
	GetCurrentPageNo = Cint(intMaxPageID /100) + 1
End IF

End Function


HTH
David

-----Original Message-----
From: Joe Rojas [mailto:JRojas at tnco-inc.com]
Sent: Friday, May 06, 2005 7:44 AM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Show only X number records at a time


Hi All,

How do sites like eBay show only X number of items at a time and allow
users to jump to a page number or click next?

Is there a SQL statement that allows you to select the 2nd
(3rd,4th,5th,...)set of X number of records in a database?

Thanks!
JR




This electronic transmission is strictly confidential to TNCO, Inc. and
intended solely for the addressee. It may contain information which is
covered by legal, professional, or other privileges. If you are not the
intended addressee, or someone authorized by the intended addressee to
receive transmissions on behalf of the addressee, you must not retain,
disclose in any form, copy, or take any action in reliance on this
transmission. If you have received this transmission in error, please
notify the sender as soon as possible and destroy this message. While
TNCO, Inc. uses virus protection, the recipient should check this email
and any attachments for the presence of viruses. TNCO, Inc. accepts no
liability for any damage caused by any virus transmitted by this email.
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



This electronic transmission is strictly confidential to TNCO, Inc. and
intended solely for the addressee. It may contain information which is
covered by legal, professional, or other privileges. If you are not the
intended addressee, or someone authorized by the intended addressee to
receive transmissions on behalf of the addressee, you must not retain,
disclose in any form, copy, or take any action in reliance on this
transmission. If you have received this transmission in error, please notify
the sender as soon as possible and destroy this message. While TNCO, Inc.
uses virus protection, the recipient should check this email and any
attachments for the presence of viruses. TNCO, Inc. accepts no liability for
any damage caused by any virus transmitted by this email.
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list