?I have a generalised routine for printing forms using Rave reports D2007.

I struck an interesting problem printing contents of a DBGrid showing 
columns from a MSSQL database - I think its because the fields are null or a 
type (eg binary) that ClientDataSets cannot display.   Printing that column 
gives an access violation.  I want to have it print nothing of course for a 
column with invalid or null or blank  data, haven't yet figured out how to 
skip them.

Here is the essential code that prints the columns of the grid, (I have 
already set tab positions scaled to widths of the columns).
- I think this particular column (column 4 in this case) has nulls.

[here lcds is a TClientDataSet, lDBGrid is a TDBGrid,  ThisField is aTField]

              for rowptr := 1 to comprowmax do
              begin
                lcds.RecNo:=rowptr;   //have to move around dataset
                for colptr := 0 to compcolmax do
                begin
                  ltext:='';
                  //column may not have a field associated...
                  if lDBGrid.Columns[colptr].Fieldname <> '' then
                  begin
                    ThisField:=lDBGrid.Columns[colptr].Field;
                    if not ThisField.IsNull then 
lText:=lDBGrid.Fields[colptr].asString;            <==access violation
                  end;
                  printtab(ltext);
                end;
                println('');
            end;

Any ideas how to bullet proof this?

John 


_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe

Reply via email to