Board index » delphi » Help with this "simple" problem

Help with this "simple" problem

I have a program with two forms.

There is a record declared in the public section of Form1.

When I call Form2, I want to change a value in the record,
ie.  TForm1.Record.Value := TForm1.Record.Value +1;

Then Form2 closes and I am back in Form1, but the value hasn't changed.  What
am I doing wrong?

Stephen LEAFS Legge
SLE...@cs.mun.ca
St. John's, Newfoundland  

 

Re:Help with this "simple" problem


Quote
Stephen L. Legge wrote:

> I have a program with two forms.

> There is a record declared in the public section of Form1.

> When I call Form2, I want to change a value in the record,
> ie.  TForm1.Record.Value := TForm1.Record.Value +1;

> Then Form2 closes and I am back in Form1, but the value hasn't changed.  What
> am I doing wrong?

        Can't be certain, but unless you changed the names of a lot of
things TForm1 is the name of a certain type, not the name of a form. There's
probably a form named Form1 around (of type TForm1) - you might try

Form1.Record.Value := Form1.Record.Value + 1;

instead. (Actually I must be missing something because I don't see
why the code you post would even compile...)

--
David Ullrich
Sig file accidentally deleted - sorry.

Re:Help with this "simple" problem


Quote
>When I call Form2, I want to change a value in the record,
>ie.  TForm1.Record.Value := TForm1.Record.Value +1;

>Then Form2 closes and I am back in Form1, but the value hasn't changed.  
>What am I doing wrong?

  Hmm, have you checked with the de{*word*81} to see that the line is actually
being executed?
=scott

Re:Help with this "simple" problem


Quote
On Wednesday, July 10, 1996, David Ullrich wrote...
> Stephen L. Legge wrote:

> > I have a program with two forms.

> > There is a record declared in the public section of Form1.

> > When I call Form2, I want to change a value in the record,
> > ie.  TForm1.Record.Value := TForm1.Record.Value +1;

> > Then Form2 closes and I am back in Form1, but the value hasn't
changed.  What
> > am I doing wrong?

>    Can't be certain, but unless you changed the names of a lot of
> things TForm1 is the name of a certain type, not the name of a form.
There's
> probably a form named Form1 around (of type TForm1) - you might try

> Form1.Record.Value := Form1.Record.Value + 1;

> instead. (Actually I must be missing something because I don't see
> why the code you post would even compile...)

To change a var in form1 from form2 put this in form2:

unit form2;

uses ....

......

implementation

uses form1;

This lets form2 access form1 public var.

Other Threads