AnsweredAssumed Answered

Limit selection based on ID

Question asked by tomlorge on Aug 11, 2013
Latest reply on Aug 12, 2013 by philmodjunk

Title

Limit selection based on ID

Post

     I have a hospital database that contains multiple contacts at the same hospital. I'm trying to limit the number of names selected to 6 or less per hospital. The script below gives me half of the available names so if there are 20 records at a hospital it is giving me 10 and if there are 6 it is giving me 3. Anyone have any thoughts?

     Sort Records [ Specified Sort Order: HOSP::HOSPID; ascending ]
     [ Restore; No dialog ]
     Go to Record/Request/Page[ First ]
     Set Variable [ $id; Value:"" ]
     Set Variable [ $counter; Value:1 ]
     Loop
     If [ HOSP::HOSPID ≠ HOSP::HOSPID ]
     Set Variable [ $id; Value:"HOSPID" ]
     Set Variable [ $counter; Value:1 ]
     End If
     If [ $counter ≥ 6 ]
     Omit Record
     Else
     Set Variable [ $counter; Value:$counter+1 ]
     End If
     Go to Record/Request/Page
     [ Next; Exit after last ]
     End Loop
      
     Any help would be appreciated.

Outcomes