Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think the answer can be found in my first comment to your question. Let's look at this code:</p> <pre><code>procedure TFRelatiebeheer.SaveCancel(Sender: TObject); begin if (DRelatiebeheer.CID.State in [dsEdit, dsInsert]) then DRelatiebeheer.CID.Post; DRelatiebeheer.AID.Post; if DRelatiebeheer.CID.Post = Action then KJSMDBGrid1.RefreshData; KJPanel4.Visible := true; end; </code></pre> <p>The indentation is off. You think that you are setting <code>KJPanel4.Visible</code> inside the <code>if</code>, but you are not. Let's correct the indentation:</p> <pre><code>procedure TFRelatiebeheer.SaveCancel(Sender: TObject); begin if (DRelatiebeheer.CID.State in [dsEdit, dsInsert]) then DRelatiebeheer.CID.Post; DRelatiebeheer.AID.Post; if DRelatiebeheer.CID.Post = Action then KJSMDBGrid1.RefreshData; KJPanel4.Visible := true; end; </code></pre> <p>Do you see what has happened?</p> <p>Correct this with <code>begin/end</code>:</p> <pre><code>procedure TFRelatiebeheer.SaveCancel(Sender: TObject); begin if (DRelatiebeheer.CID.State in [dsEdit, dsInsert]) then DRelatiebeheer.CID.Post; DRelatiebeheer.AID.Post; if DRelatiebeheer.CID.Post = Action then begin KJSMDBGrid1.RefreshData; KJPanel4.Visible := true; end; end; </code></pre> <p>For what it is worth, where I work, our coding standard demands the use of <a href="http://docwiki.embarcadero.com/RADStudio/XE5/en/Declarations_and_Statements#Compound_Statements" rel="nofollow">compound statements</a>, with <code>begin/end</code>, and forbids the use of the single statement variant. In the past 15 years since we introduced this rule, we have not once encountered this mistake. Niklas Wirth knew that he had got it wrong and corrected the mistake in Modula-2. But it's simple enough to avoid the problem yourself just by forsaking single statement syntax.</p> <hr> <p>Update, as you and others point out, <code>if DRelatiebeheer.CID.Post = Action then</code> looks dubious. I honestly don't know enough about the classes that you are using to recommend a solution to that problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload