Topic: Next Button
Hi friends,
Can any one help or guide to use next button function. Next>? Any project sample?
My Visual Database → General → Next Button
Hi friends,
Can any one help or guide to use next button function. Next>? Any project sample?
unforgettable,
What you need is something along the lines below. I don't normally have a button, I tend to use an 'on_cell_click' event of a tablegrid, so you'll need to play around with the code below.
I'm sure there is an easier way, but it isn't springing to mind at the moment.
You need to set up a dataset and then use your next button to action the function dataset.next.
Here is some code:
procedure next(nextrow: integer);
var
index,count : integer; //loop counter
ds : TDataSet; //dataset to read your database
begin
count := SQLExecute('SELECT count(*) FROM tablename); //get maximum rows in table
SQLQuery('SELECT column(s)_you_want FROM table', ds); //read in your database and hold it in DS
ds.first; // make sure you are at the beginning of the data
for index := 0 to count-1 do
begin
//here you need an array a table grid or edit boxes whatever you are viewing the table in
array[index] := ds.fFieldByName('a _field_in_your_database').asString;
ds.next; // this is the bit you need to have in your button click
end;
ds.close;
end;
What you could do, is have the index increment in the button click event, and call your next procedure. In the procedure remove the for loop and pass in the index parameter and then use 'nextRow' instead if index above. In other words it would be array[nextRow] := ....... instead of array[index].
Sorry I'm a little unclear, I'm trying to get my project running some extra stuff for tomorrow and it is past 8pm here and I'm running out of time.
I've just had a further thought. If you are using a tablegrid to view your records, you could use the ARow parameter from the cell_on_click event as your counter and just add 1 to that.
My Visual Database → General → Next Button
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi