Source language: Translate to:

dbpro next page

Questions about our Advanced Database plug-in

Moderator: Neosoft Support

dbpro next page

Postby yanzco » Sat Mar 28, 2015 12:06 am

i was wondering if anyone have idea how do i have a button that would work like next page / previous page of records..

records is set show all.. so i have so many records in the grid..

the thing is computer lags a little with the mouse scroll up and down..
so i would just prevent mouse scroll, and have next batch of the records.. like next page and previous page..

in a grid, i can display 27 records...

i tried go to record 28 then next page +28
or prev page -28

but failed..
yanzco
 
Posts: 175
Joined: Sun Jul 20, 2014 4:07 am

Re: dbpro next page

Postby Gaev » Sat Mar 28, 2015 4:56 am

yanzco:

i tried go to record 28 then next page +28
or prev page -28

but failed..

1) Post the exact script/code you tried.

2) Describe in detail what you mean by "failed".
User avatar
Gaev
 
Posts: 3716
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: dbpro next page

Postby Danito » Sat Mar 28, 2015 12:46 pm

Try

START
Code: Select all
dbpOpenAccessDatabase "ID" "DATA_BASE"
dbpExecSQL "ID" "select top 27 * from TABLA" ""


button nex page
Code: Select all
Math "[ID.TABLA.$recCount]+27" "0" "[registros]"
dbpExecSQL "te" "SELECT top [registros] * FROM inventario" ""
dbpGotoRecord "te" "inventario" "[te.inventario.$recCount]"


button prev page
Code: Select all
Math "[ID.TABLA.$recCount]-27" "0" "[registros]"
dbpExecSQL "te" "SELECT top [registros] * FROM inventario" ""
dbpGotoRecord "te" "inventario" "[te.inventario.$recCount]"
User avatar
Danito
 
Posts: 51
Joined: Thu Mar 11, 2010 7:07 pm

Re: dbpro next page

Postby Gaev » Sat Mar 28, 2015 2:35 pm

Danito:

The definition of [ID.Table.$RecCount] in the Help file is ...
If a query is active, the result reflects the number of found records. When no query is active, the result reflects the total number of records in the database.


So, if there are 100 records in your Database/Query, [ID.TABLA.$recCount]+27 will return will return 127 ... so, later, when you do ...
Code: Select all
SELECT top [registros] * FROM inventario

... you are asking to see record 127 ... which does NOT exist.


I suggest you calculate the last page number (starting with page 0) ...
Code: Select all
SetVar "[QueryRecordCount]" "[ID.TABLA.$RecCount]"

Math "trunc([QueryRecordCount]/27)" "0" "[truncated]"
Math "[QueryRecordCount]-([truncated]*27)" "0" "[difference]"
If "[difference]" ">" "0"
    Math "[truncated]" "0" "[LastGridPage]"
Else
    Math "[truncated]-1" "0" "[LastGridPage]"
EndIf

... and reserve a variable for the current page being viewed ...
Code: Select all
SetVar "[CurrentGridPage]" "0"



Now, whenever user requests the Next GridPage ...
Code: Select all
If [CurrentGridPage]" "[LastGridPage]"
   AlertBox "Error" "You are on the last page"
Else
   Math "[CurrentGridPage]+1" "0" "[CurrentGridPage]"
   Math "([CurrentPage]*27)+1" "0" "[RecordAtStartOfPage]"
   dbpGotoRecord "te" "inventario" "[RecordAtStartOfPage]"
EndIf


Same for ...

Previous GridPage ... check for [CurrentPagePage] = 0
First GridPage ... set [CurrentPagePage] to 0
Last GridPage ... set [CurrentPagePage] to [LastGridPage]


Have not tried it myself ... so there might be typos ... if problematic, check values of different variables in Debugger.

Note: If you allow inserts of records, you will need to recalculate [LastGridPage] at each request of a page change.
User avatar
Gaev
 
Posts: 3716
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: dbpro next page

Postby Danito » Sat Mar 28, 2015 6:41 pm

a mi me funciona... use un select top 27 despues de abrir la tabla... pero sin duda tu solucion es perfecta
User avatar
Danito
 
Posts: 51
Joined: Thu Mar 11, 2010 7:07 pm


Return to NeoBookDBPro

Who is online

Users browsing this forum: No registered users and 1 guest