<HTML><HEAD></HEAD>
<BODY dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Arial'; COLOR: #000000; FONT-SIZE: 12pt">
<DIV>I am wishing to use a ClientDataSet for custom data, not read from a
database, and with varying formats. This means that field
definitions and populating it are all done at run time.</DIV>
<DIV> </DIV>
<DIV>The data has some integer values that are 8 digit dates, and some that are
IRD numbers and I want to format them to show in controls – eg IRD numbers as
10-000-033 for example.</DIV>
<DIV> </DIV>
<DIV>The code I am using below does work fine for displaying data on the screen,
but not for printing – the printing line in the report (Rave D2007) uses a line
in a loop like:</DIV>
<DIV> </DIV>
<DIV>ThisField:=lDBGrid.Columns[colptr].Field;</DIV>
<DIV>if not ThisField.IsNull then lText:=lDBGrid.Fields[colptr].asString;</DIV>
<DIV> </DIV>
<DIV>But getting the value asString does not get the Display format – i get
10000033 for example, so pretty useless for a report.</DIV>
<DIV> </DIV>
<DIV>Anyone have an idea what more I can do to get the printing also use the
DisplayFormat ?</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Below is how I create the Dataset.</DIV>
<DIV> </DIV>
<DIV>(Eventually I would like to add some events to reformat the integer dates,
so that instead of displaying as YYYY-MM-DD they can be displayed as DD-MM-YYYY
but I am not sure that is possible – so first things first).</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> ClientDataSet1.Fields.Clear;</DIV>
<DIV> with ClientDataSet1 do</DIV>
<DIV> begin</DIV>
<DIV> with TIntegerField.Create(Self) do</DIV>
<DIV> begin</DIV>
<DIV> Name :=
'ClientDataSet1RNO';</DIV>
<DIV> FieldKind := fkData;</DIV>
<DIV> FieldName := 'RNO';</DIV>
<DIV> DataSet := ClientDataSet1;</DIV>
<DIV> end; //FieldName</DIV>
<DIV> with TStringField.Create(Self) do</DIV>
<DIV> begin</DIV>
<DIV> Name :=
'ClientDataSet1Alpha1';</DIV>
<DIV> FieldKind := fkData;</DIV>
<DIV> FieldName := 'Alpha1';</DIV>
<DIV> Size := 10;</DIV>
<DIV> DataSet := ClientDataSet1;</DIV>
<DIV> end; //FieldName</DIV>
<DIV> with TDateField.Create(Self) do</DIV>
<DIV> begin</DIV>
<DIV> Name :=
'ClientDataSet1Date1';</DIV>
<DIV> FieldKind := fkData;</DIV>
<DIV> FieldName := 'Date1';</DIV>
<DIV> DataSet := ClientDataSet1;</DIV>
<DIV> end; //FieldName</DIV>
<DIV> with TFloatField.Create(Self) do</DIV>
<DIV> begin</DIV>
<DIV> Name :=
'ClientDataSet1Float1';</DIV>
<DIV> FieldKind := fkData;</DIV>
<DIV> FieldName := 'Float1';</DIV>
<DIV> DataSet := ClientDataSet1;</DIV>
<DIV> end; //FieldName</DIV>
<DIV> with TIntegerField.Create(Self) do</DIV>
<DIV> begin</DIV>
<DIV> Name :=
'ClientDataSet1DDate1';</DIV>
<DIV> FieldKind := fkData;</DIV>
<DIV> FieldName := 'DDate1';</DIV>
<DIV> DataSet := ClientDataSet1;</DIV>
<DIV> end; //FieldName</DIV>
<DIV> with TIntegerField.Create(Self) do</DIV>
<DIV> begin</DIV>
<DIV> Name :=
'ClientDataSetCLIRD1';</DIV>
<DIV> FieldKind := fkData;</DIV>
<DIV> FieldName := 'CLIRD1';</DIV>
<DIV> DataSet := ClientDataSet1;</DIV>
<DIV> end; //FieldName</DIV>
<DIV> end;</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> TIntegerField(ClientDataSet1.FieldByName('CLIRD1')).DisplayFormat :=
'000-000-000';</DIV>
<DIV> TIntegerField(ClientDataSet1.FieldByName('DDate1')).DisplayFormat :=
'0000-00-00';</DIV>
<DIV> </DIV>
<DIV> TIntegerField(ClientDataSet1.FieldByName('CLIRD1')).EditFormat :=
'#';</DIV>
<DIV> </DIV>
<DIV> ClientDataset1.CreateDataset;</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV style="FONT-FAMILY: 'Arial'; COLOR: #000000; FONT-SIZE: 12pt">John
Bird<BR></DIV></DIV></DIV></BODY></HTML>