I have recently been re-visiting the function of a two-state button on a form and thought that would be great to be able to do in a browse. I have a logical field in my table, STATUS that uses a somewhat reverse logic to show Active and Inactive records. The default is .F. for Active and .T. for Inactive so the user only needs to make a status change if the record is no longer a valid choice. Its just one less step on data entry since a new record is undoubtedly considered active at that time. On the form the button text toggles "Active" and "Inactive", but on the browse under the Active column I just want it to say "Yes" or "No" - (which a checkbox doesn't do in case anyone was thinking why didn't I just do that. The answer is because then I can change the font color so INACTIVE stands out - see the dynamic properties for the form button & also properties using font and color equations)
To do this in a browse I added a Generic button from the Browse Control toolbox. I set the display as text only and discovered there was an expression smart field available to define the text. Since the button is System->Unbound, ie. not bound to a field in the table, I used an if() condition to test the status field's value: if(status,"No","Yes") - (sounds simple but took me a while to figure that out).
Click on the Actions ('Active') column (initially will say Generic - you can change that) to highlight and select Edit Display Format from the right click menu (if the column is narrow you may have to widen it to get that menu option to show up). Choose 'all rows have the same display format', then click Edit Display Format to add the button and edit the code. Also add the Justify selection above the button so it is centered in the column. Actually you could just add a 'normal' button and include a text object next to it, but that's not what I wanted to do.
Since I have 2 buttons in this browse, there are 2 functions added to the browse Events-Events, the Actions2_Buttonclick event is the one for this button. All it does is - based on the current value of the status field for the current record (which is not displayed in the browse); changes the underlying table record then calls for a repaint of the button so the calc expression can show its new value.
I hope others who post here will help keep the desktop alive by showing all the nifty things that can be done using Alpha's built in tools. Most of the old links are gone in here so this is my hopeful attempt to bring 'em back!
BrwBtn_170115.zip
To do this in a browse I added a Generic button from the Browse Control toolbox. I set the display as text only and discovered there was an expression smart field available to define the text. Since the button is System->Unbound, ie. not bound to a field in the table, I used an if() condition to test the status field's value: if(status,"No","Yes") - (sounds simple but took me a while to figure that out).
Click on the Actions ('Active') column (initially will say Generic - you can change that) to highlight and select Edit Display Format from the right click menu (if the column is narrow you may have to widen it to get that menu option to show up). Choose 'all rows have the same display format', then click Edit Display Format to add the button and edit the code. Also add the Justify selection above the button so it is centered in the column. Actually you could just add a 'normal' button and include a text object next to it, but that's not what I wanted to do.
Since I have 2 buttons in this browse, there are 2 functions added to the browse Events-Events, the Actions2_Buttonclick event is the one for this button. All it does is - based on the current value of the status field for the current record (which is not displayed in the browse); changes the underlying table record then calls for a repaint of the button so the calc expression can show its new value.
I hope others who post here will help keep the desktop alive by showing all the nifty things that can be done using Alpha's built in tools. Most of the old links are gone in here so this is my hopeful attempt to bring 'em back!
BrwBtn_170115.zip