Hi
I have a database that has records with 8 fields relating to the
address. Any one of these fields could be empty/blank. When I generate
my reports I need the address to print without the blanks. For example
if the county has been left blank:
1 Kings Street
Morden
SM4 5DF
Should look like:
1 Kings Street
Morden
SM4 5DF
Unfortunatly the reporting components I'm using cant automatically do
this :(
I thought i had overcome the problem by creating a global string list
and adding non blank lines, ie using the procedure createAddress shown
below.
I can then use the tstringlist values by passing them as variables to
the report, using a procedure that runs as the report is created
containing code such as:
if CompareText(VarName, 'line1') = 0 then
value:=addresslist.address[0];
This is fine for one report! :(
However, I need this to be done for any number records. Therefore I
need some form of dynamic data structure that can contain a
tstringlist for each record.
I have looked at tlist and assume I can do something like:
addresslist:=tlist.Create;
while not qryMailinglist.Eof do
begin
Address:= TStringList.Create;
createAddress(address);
addresslist.Add(address)
end;
but cant get my head around the syntax I would need to access each
stringlist.
Any comments on better ways, or how to access the values appreciated :)
Many thanks
Pete
procedure createAddress
begin
if (qryMailingList.fieldbyname('ADDRESS1').asstring<>'') then
address.Add(qryMailingList.fieldbyname('ADDRESS1').asstring);
if (qryMailingList.fieldbyname('ADDRESS2').asstring<>'') then
address.Add(qryMailingList.fieldbyname('ADDRESS2').asstring);
if (qryMailingList.fieldbyname('ADDRESS3').asstring<>'') then
address.Add(qryMailingList.fieldbyname('ADDRESS3').asstring);
if (qryMailingList.fieldbyname('ADDRESS4').asstring<>'') then
address.Add(qryMailingList.fieldbyname('ADDRESS4').asstring);
if (qryMailingList.fieldbyname('TOWN').asstring<>'') then
address.Add(qryMailingList.fieldbyname('TOWN').asstring);
if (qryMailingList.fieldbyname('COUNTY').asstring<>'') then
address.Add(qryMailingList.fieldbyname('COUNTY').asstring);
if (qryMailingList.fieldbyname('COUNTRY').asstring<>'') then
address.Add(qryMailingList.fieldbyname('COUNTRY').asstring);
if (qryMailingList.fieldbyname('POSTCODE').asstring<>'') then
address.Add(qryMailingList.fieldbyname('POSTCODE').asstring);
end;
------------------------ Yahoo! Groups Sponsor --------------------~-->
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/i7folB/TM
--------------------------------------------------------------------~->
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/delphi-en/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/