Select Button template does Not Disable when Browse has No Records - Fix CtlBrowA.TPW - Legacy Only

The Legacy Browse box Select button does not disable when there are “No Records” as is done with Change, Delete and View. The Popup menu correctly disables the ‘~Select’ item. ABC works right.

Clicking the Select button will return a cleared record and Request=Completed which may not work for the caller. Typically this is not a problem as most Select browses do have records. I noticed because I have filters that removed all records.

It’s easy fix by editing CTLBrowA.TPW. The #CONTROL(BrowseSelectButton...) template is first in the file. About line 95 you’ll find this existing code:

  #IF(%SelectControl AND %SelectViaPopup)

Under the above #ENDAT add the below lines. I copied them from BrowseViewButton and changed %ViewControl to %SelectControl:

#! ==== Added below 06/29/21 so SELECT will be disabled when no records ====
#! Code copied from View button below
  #IF(%Control = %ListControl)
%SelectControl{PROP:Disable} = 1
  #IF(%Control = %ListControl)
IF LocalRequest = SelectRecord THEN %SelectControl{PROP:Disable} = 0.
#! ==== Added above 06/29/21 so SELECT will be disabled when no records ====

The above template change generates the 2 lines tagged “<=== New” to Enable/Disable Select:

BRW1::RefreshPage ROUTINE
  IF BRW1::RecordCount
    DO BRW1::FillBuffer
    IF LocalRequest = SelectRecord THEN ?Select:2{PROP:Disable} = 0. !<=== New  ===
    ?View{PROP:Disable} = 0
    ?Change:3{PROP:Disable} = 0
    ?Delete:3{PROP:Disable} = 0
    BRW1::CurrentChoice = 0
    ?Select:2{PROP:Disable} = 1  !<=== New === Disable Select when No Records
    ?View{PROP:Disable} = 1
    ?Change:3{PROP:Disable} = 1
    ?Delete:3{PROP:Disable} = 1
  BRW1::RefreshMode = 0

Note: when Select is Disabled=1 I left out the check IF LocalRequest = SelectRecord that’s done when there are records. It could easily be done, I didn’t see the need.

Example of Browse before fix showing with no records Select is not disabled like View, Change and Delete. Copy should have been disabled.

Example of Browse before fix showing with No Records that Select is Enabled while View, Change and Delete are Disabled. Copy should have been Disabled.


1 Like