• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
      • Introduction to CSPro Language
      • Data Requirements
      • CSPro Program Structure
      • Programming Standards
      • Code Folding
      • Debugging CSPro Applications
      • Declaration Section
      • Procedural Sections
        • Statements
        • Proc Statement
        • PreProc Statement
        • OnFocus Statement
        • OnOccChange Statement
        • KillFocus Statement
        • PostProc Statement
      • Logic
      • Language Elements
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

OnFocus Statement

Format
onfocus
Description
The onfocus statement declares that the statements following it are executed when a form, roster, or field becomes active.
Statements in an onfocus procedure are executed when you move onto the object in which they are coded. When moving forward, any preproc statements are executed before the onfocus statements. However, when moving backward, the preproc statements are not executed and only the onfocus statements are executed.
Example
PROC CHRONIC_ILLNESS

onfocus

   
if curocc() = 1 then
       
setvalueset(CHRONIC_ILLNESS,CHRONIC_ILLNESS_FIRST_VS);

   
else
       
setvalueset(CHRONIC_ILLNESS,CHRONIC_ILLNESS_SECOND_VS);

   
endif;
See also: Proc Statement, PreProc Statement, OnOccChange Statement, KillFocus Statement, PostProc Statement, Order of Executing Data Entry Events, Order of Executing Batch Edit Events