mercredi 16 septembre 2020

Getting an access error trying to set a checkbox to checked

I'm using Delphi 10.4 Pro with all updates and I'm experiencing an application access error with one line of code and I have NO idea why. It's a very simple checking of a checkbox at form creation based on a boolean variable that is set when the main program window opens. If I comment out the line I experience NO error when opening the window. The access error appears the first time I open the options window in the app and usually not after that, no matter how many times I close and open the options window in my program. (!?!?!?)

Here is the options window FormCreate code:

procedure TOptionsForm.FormCreate(Sender: TObject);
begin
  RzLabel2.Caption := ARProVerLong;
  Caption := ARProVer + ' Options/About';

  If Use386 Then Begin
    Using386 := '3.86';
    CSConstant.ItemIndex := 0;
  End Else Begin
    Using386 := '3.87';
    CSConstant.ItemIndex := 1;
  End;

  MainDecPrecBox.Text := IntToStr(TV);
  If AutoUp = 1 Then AutoUpCB.Checked := True;
  if English = 1 Then PrefEngCB.Checked := True;
  DSWeight.Text := FTS(DragSledWeight);
  if SoundAtStartup = 1 then SoSUOnCB.Checked := True;
  SGOnCB.Checked := UseStartupGuide;       {<--- This line works with no error!}
  BackupPMDBCBox.Checked := DoBackupPMDB;  {<--- This is the line causing the access error!}
  CalcBox1.ItemIndex := UseCalc;
  WordProcProgramEdit.Caption := WordP;
  CadProgramEdit.Caption := CaddProgram;
  MRUNum.Text := IntToStr(MRUNo);
  VerLabel.Caption := ProVersion;

  case IconColor of
  45: Blue15.Down := True;
  46: Green15.Down := True;
  47: Red15.Down := True;
  48: Yellow15.Down := True;
  49: Tree.Down := True;
  57: Black15.Down := True;
  58: Maroon15.Down := True;
  59: Orange15.Down := True;
  end;
end;'

I've tried everything I can think of to try to get this one line to work, such as deleting and recreating the checkbox from scratch, rewording the code to longer less efficient wording, moving it to the form OnShow event, rebooting my computer in case of a Windows memory issue, taking the code away from the Action Manager and putting it in the options window.... Nothing has worked!! I'm at my wits end!

If anyone has a suggestion I'm all ears!!

Thanks in advance!!

Kelly Young Dirigo Software, LLC




Aucun commentaire:

Enregistrer un commentaire