Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange behaviour of a variable. Why?

Status
Not open for further replies.

delphiman

Programmer
Dec 13, 2001
422
ZA


In the code below

qryMyQueryField1.value has a value of 1
qryMyQueryField2.value has a value of 2001


A breakpoint put on Line A (below) reveals that

OppField1 has faithfully assumed the value of qryMyQueryField1.value;
But OppField2 remains 0

Can someone tell me why OppField2 should remain 0 please?


procedure TfrmMyForm.grdMyGridDblClick(Sender: TObject);
var
OppField1, OppField2 : real;

begin
OppField1 := qryMyQueryField1.value;
OppField2 := qryMyQueryField2.value;
end; .............. Line A
 
For anyone interested in this thread I'm not even going to attempt to explain why this problem arises but ....

I have (long ago) discovered that a TDataSource component
should be treated with suspicion when things which worked
before suddenly don't behave after changes have been made to a table. And all too often simply deleteting the TDataSource and installing one all over again from the pallet solves the problem.

In this instance I had made a change to the Table whereby I had made an AutoIncrement field the Index to the Table.
Apparently the TDataSource did not (doesn't) "see" this.

Replacing the TDataSource as above solved the problem.

Why this should give rise to this particular problem is too much for my tiny mind. :) :)
 
Code:
procedure TfrmMyForm.grdMyGridDblClick(Sender: TObject);
var
  OppField1, OppField2 : real; 

begin
 OppField1 := qryMyQueryField1.value;
 OppField2 := qryMyQueryField2.value;
end;
The Delphi compiler is actually quite smart and realises that there is no point in executing this code (it will have no oveeffect) and hence doesn't generate it.


Andrew
Hampshire, UK
 
Code:
procedure TfrmMyForm.grdMyGridDblClick(Sender: TObject);
var
  OppField1, OppField2 : real; 

begin
 OppField1 := qryMyQueryField1.value;
 OppField2 := qryMyQueryField2.value;
end;
The Delphi compiler is actually quite smart and realises that there is no point in executing this code (it will have no overall effect) and hence doesn't generate it.


Andrew
Hampshire, UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top