Very new at this, so excuse the perhaps easy question.
I have a range of fields from field x to field y, that I would like to "empty" in all records by setting them to either 0 or '' with modifyall in a switch case depending on their datatype.
I'm unsure how to iterate through just the fields from x to y.
0
Comments
OnAfterGetRecord()
CLEAR(Fieldx)
CLEAR(Fieldy)
Modify;
You're trying to clear out certain fields? Or all fields?
http://www.BiloBeauty.com
http://www.autismspeaks.org
Sorry, but I posted in the wrong section of the forum. Hopefully a mod can move it.
Been trying to work it out with either Field or Object, but can't seem to get Modifyall working in regards to the fieldname. It needs a record.
If you are looking for updating blank and zero values dynamically on a table (on a range of fields, starting from x to y) the following code can help. (I am considering the field id range from 50000 to 50002)
// First create 3 fields in the Vendor (23) Table like:
// ID Name Type Length
// 50000 Dec Decimal
// 50001 Txt Text 30
// 50002 Cod Code 10
Create a new report, take Vendor table (23) as a dataitem and put the following code in OnAfterGetRecord trigger.
// Variables used:
// Name Type Length
// TbRecRef RecordFef
// TbFieldRef FieldRef
// PString text 30
// TbFieldName text 30
// TbDataType text 30
CLEAR(TbRecRef);
TbRecRef.OPEN(23); // Vendor Table
TbRecRef.GETTABLE(Vendor);
PString := Vendor.GETPOSITION();
TbRecRef.SETPOSITION(PString);
FOR i := 50000 TO 50002 DO BEGIN
TbFieldRef := TbRecRef.FIELD(i);
TbFieldName := TbFieldRef.NAME;
TbDataType := FORMAT(TbFieldRef.TYPE);
CASE TbDataType OF
'Code', 'Text': TbFieldRef.VALUE := '';
'Integer': TbFieldRef.VALUE := 0;
'Decimal': TbFieldRef.VALUE := 0;
END;
END;
TbRecRef.MODIFY;
TbRecRef.CLOSE;
Before running the report, put some values in the fields, Dec, Cod and Txt so that you can check the execution.
Hope this helps.
Chn
Best Regards.