Here is how I populate my textfields on my maintenance screen when a user clicks a ListView item.

The index to the record in the database is stored as the last column in each ListView row so I can

Use it to quickly/easily lookup the database row to fetch the memo fields in their entirety.

 

sub ListView_ItemClick {

  

        my $ls_text="";           #-- ls for local scalar

        my $ls_ret="";

        my $ls_error="";

        my $ls_index="";

        my $ls_sqltxt="";

        my %lh_data=();          #-- lh for local hash

  

       $gs_item = shift;           #-- gs for global scalar

 

       $ls_ret = Open_Database();  if ($ls_ret) {return 1;}

 

       %lh_data  = $LV->ItemInfo($gs_item,36);  #-- record index

 

       $ls_index = $lh_data{-text}; 

 

       $ls_sqltxt="SELECT Comments, [In House Comments], [Analysis Proposed Fix], Issue FROM Tracker WHERE Index = $ls_index";

 

       $ls_ret = $gs_db->Sql($ls_sqltxt);

 

       If ($ls_ret) {

             $ls_error=$gs_db->Error();      #-- get database error msg

             Close_Database();

             Win32::GUI::MessageBox($W,$ls_error, "CPS Issue Tracker - Maintenance Screen - SQL Error($ls_ret)",16,);

             Win32::GUI::MessageBox($W,$ls_sqltxt,"CPS Issue Tracker - Maintenance Screen - SQL Cmd",16,);

             Win32::GUI::MessageBox($W,"Can't Get Memo Fields From Database", "CPS Issue Tracker - Maintenance Screen",64,);

            return 1;

       }

 

      $gs_db->FetchRow();

 

      $ls_text = $gs_db->Data("Comments");                           $TF_Comments->Text($ls_text);

      $ls_text = $gs_db->Data("Analysis Proposed Fix");          $TF_ProposedFix->Text($ls_text);

      $ls_text = $gs_db->Data("In House Comments");             $TF_InHouse->Text($ls_text);

      $ls_text = $gs_db->Data("Issue");                                   $TF_Issue->Text($ls_text);

 

      Close_Database();

     

      #-- additional code for the event follows but not shown here

}

 

sub Open_Database() {

 

       my $ls_FILEDSN="FILEDSN=$gs_cwd\\Tracker.dsn;PWD=Win32Gui102";

 

       #-- we don't want to show password if an error occurs so use this string as error msg

       my $ls_FILEDSN2="FILEDSN=$gs_cwd\\Tracker.dsn";

 

      $gs_db = new Win32::ODBC($ls_FILEDSN);

 

      if (! $gs_db) {

            my $ls_error=Win32::ODBC::Error();

            Win32::GUI::MessageBox($W,

                    "Can't Establish Database Connection using:\n$ls_FILEDSN2\n$ls_error",

                    "CPS Issue Tracker - Error",16,);

            return 1;   

     }

     return 0;

}

 

sub Close_Database() {

      $gs_db->Close(); 

       undef $gs_db;

}