Tech Tip: Simulating Button State for PREVIOUS and NEXT RECORD Command
PRODUCT: 4D | VERSION: 12.2 | PLATFORM: Mac & Win
Published On: July 11, 2011
When a button is assigned to use a standard action like Previous Record and Next Record, 4D automatically handles the button state you. However, these standard actions (specifically the one that deals with record navigation) can be used and work only in a form that belongs to the table you are accessing the data from.
If you are using the command PREVIOUS RECORD and NEXT RECORD instead of the standard action, you must handle the button state yourself. Here is a utility method that can be called are the execution of the command PREVIOUS RECORD and NEXT RECORD to update the button state.
// Method: NavButtonControl // Parameters // $1 - Pointer to table // $2 - Pointer to the Variable of a Previous Record Button // $3 - Pointer to the Variable of a Next Record Button // ---------------------------------------------------- C_POINTER($1;$table_p) C_POINTER($2;$prevButton_p) C_POINTER($3;$nextButton_p) If (Count parameters>=3) $table_p:=$1 $prevButton_p:=$2 $nextButton_p:=$3 If (Selected record number($table_p->)<=1) | (Is new record($table_p->)) DISABLE BUTTON($prevButton_p->) Else ENABLE BUTTON($prevButton_p->) End if If (Selected record number($table_p->)=Records in selection($table_p->))\ | (Is new record($table_p->)) DISABLE BUTTON($nextButton_p->) Else ENABLE BUTTON($nextButton_p->) End if End if |
Example:
NEXT RECORD([Table_1]) NavButtonControl(->[Table_1];->PrevButton;->NextButton) |
PREVIOUS RECORD([Table_1]) NavButtonControl(->[Table_1];->PrevButton;->NextButton) |