Label OnGetText() Problem
I'm having a problem in a label where I'm using the OnGetText() event in RAP
(10.07).
Here is the code:
Text := DateToStr(Trunc(Invoice_Statements['CYCLE_START_DATE']))
+ ' to ' + DateToStr(Trunc(Invoice_Statements['CYCLE_END_DATE']));
The exception I'm getting is:
EVariantTypeCastError 'Could not convert variant of type (Null) into type
(Double)'
However, changing the code in this event to the following results in the
text being set to 'NOT NULL':
if Invoice_Statements.FieldObjects['CYCLE_START_DATE'].IsNull then
Text := 'NULL'
else
Text := 'NOT NULL';
Finally, using the following code results in empty strings (i.e. just ' to '
is displayed):
Text := (Invoice_Statements.FieldObjects['CYCLE_START_DATE'].AsString)
+ ' to ' + (Invoice_Statements.FieldObjects['CYCLE_END_DATE'].AsString);
The first question I have is why is the first code snippet reporting that
the values are NULL, when in fact they aren't.
Secondly, I'm trying to figure out why the final snippet of code is
returning these datetime columns as empty strings. Simply dropping these
columns from the data tree in the designer shows that they contain valid
values.
We've tried 10.08, but this did not solve the problem. I can't remember the
last time we tested this report, but I'm sure it was prior to 10.07.
Any insight into this matter is greatly appreciated.
Thanks,
Doug
(10.07).
Here is the code:
Text := DateToStr(Trunc(Invoice_Statements['CYCLE_START_DATE']))
+ ' to ' + DateToStr(Trunc(Invoice_Statements['CYCLE_END_DATE']));
The exception I'm getting is:
EVariantTypeCastError 'Could not convert variant of type (Null) into type
(Double)'
However, changing the code in this event to the following results in the
text being set to 'NOT NULL':
if Invoice_Statements.FieldObjects['CYCLE_START_DATE'].IsNull then
Text := 'NULL'
else
Text := 'NOT NULL';
Finally, using the following code results in empty strings (i.e. just ' to '
is displayed):
Text := (Invoice_Statements.FieldObjects['CYCLE_START_DATE'].AsString)
+ ' to ' + (Invoice_Statements.FieldObjects['CYCLE_END_DATE'].AsString);
The first question I have is why is the first code snippet reporting that
the values are NULL, when in fact they aren't.
Secondly, I'm trying to figure out why the final snippet of code is
returning these datetime columns as empty strings. Simply dropping these
columns from the data tree in the designer shows that they contain valid
values.
We've tried 10.08, but this did not solve the problem. I can't remember the
last time we tested this report, but I'm sure it was prior to 10.07.
Any insight into this matter is greatly appreciated.
Thanks,
Doug
This discussion has been closed.
Comments
if Invoice_Statements.FieldObjects['CYCLE_START_DATE'].IsNull then
Text := 'CYCLE_START_DATE = NULL'
else
Text := 'CYCLE_START_DATE <> NULL';
if Invoice_Statements.FieldObjects['CYCLE_END_DATE'].IsNull then
Text := Text + '; CYCLE_END_DATE = NULL'
else
Text := Text + '; CYCLE_END_DATE <> NULL';
Any other ideas for a work-around?
Thanks,
Doug
for that.
Ed Dressel
Try the following:
if (Invoice_Statements.FieldObjects['CYCLE_START_DATE'].IsNull = True) then
Text := 'CYCLE_START_DATE = NULL'
else
Text := 'CYCLE_START_DATE <> NULL';
I've seen instances where RB fails comparison statements if they are not
wrapped in parenthesis and include a direct comparison value, even when the
statement evaluates to a match.
--
---------------------------------------
Terry Swiers
Millennium Software, LLC
http://www.1000years.com
http://www.atrex.com
Atrex Inventory Control/POS -
Big business features without spending big business bucks!
Atrex Electronic Support Options:
Atrex Knowledgebase: http://www.atrex.com/atrexkb.asp
Email: mailto:support@atrex.com
than identifying whether or not there's a bug in ReportBuilder.
The OnGetText() event doesn't even work with simple string columns in the
detail band such as:
Text := Invoice_Statements['ENTRY_TYPE_DESCRIPTION'];
A DBText field placed in the designer right next to the label with the above
OnGetText() event displays the correct data.
Are you aware of any bugs that would cause this problem? Can you get the
OnGetText() event to work?
Thanks,
Doug
can't event get the OnGetText() event to work with simple string columns
that otherwise display correctly when added to the designer as a DBText
field.
Text := Invoice_Statements['ENTRY_TYPE_DESCRIPTION'];
Doug
www.RetireNeeds.com/misc/RBGetText.zip
I'm using RB 10.07 with the patches--you might want to try the latest 10.08.
Ed Dressel
Team DM
Please upgrade to the latest version of ReportBuilder (10.08) and re-test
your RAP code. As a rule of thumb, it is always best to get your report
working in Delphi first, then move the code to RAP. This makes it easier to
debug simple issues that otherwise would be unseen.
Send your serial number and purchasing email address to
info@digital-metaphors.com for upgrade instructions.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
I found the problem and it was indeed a problem with the application.
Essentially, it is iterating through the data views (TdaQueryDataView) to
retrieve the SQL statement via the TdaSQL objects.
Then, a search and replace function is used to replace instances of specific
parameter names in the SQL statement as such:
UpdatedSQLText := daSQL.SQLText.Text;
ReplaceParams(UpdateSQLText);
daSQL.EditSQLAsText := True;
daSQL.SQLText.Assign(UpdatedSQLText);
After some experimentation, removing the call to "daSQL.EditSQLAsText :=
True;" solved the problem, although I have no idea why, other than this
function worked with an earlier version of RB and has been now deprecated.
While this code was written some time ago and seems to work now, I was
wondering if you could point me toward documentation or a tech-tip and/or
demo that describes the "officially sanctioned" method for replacing
parameters in the embedded SQL statement when running a report. Note that
the SQL embedded in the report contains multiple SQL statements and
currently some of the text in the statment don't correspond to just select
or where clauses (i.e. declare int @MyVar = ). From what I've seen
in the documentation so far, it looks like the TdaSQLBuilder class should be
used for this purpose.
On another note, is there a way to programmatically disable the validation
of the SQL Script when exiting the Query Designer from the Data tab in the
Report Designer?
Thanks again,
Doug
you've burried this deep in a thread--you should post starting a new
thread--and that is a DADE ng :-)
Ed Dressel
Doug
that upgrading to RB 10.08 was also a requirement to get all of the
functionality working. With .07, only some of the issues were fixed.
Doug