I think I found a bug in TWPMMDataProvider.DoMergeGetText. When you run the mail merge and your template contains a field and your data source doesn't contain this field then you get an access violation on line 1200 in unit wpdbrich.
The original source is like that:
if (dataset <> nil) and dataset.Active then begin field := dataset.FindField(fieldname); if FShowFieldNames then begin if field <> nil then Contents.StringValue := field.DisplayName else Contents.StringValue := fieldname; if FAppendSpaceToNonEmpty and (Contents.StringValue <> '') then Contents.StringValue := Contents.StringValue + #32; Done := TRUE; end else if field.isnull then // <- IT CRASHES HERE! begin Contents.StringValue := ''; done := true; end
The variable 'field' can be null and then calling field.isnull is not possible. The following change fixes the problem:
if (field <> nil) AND field.isnull then // <- NOW IT CAN'T CRASH
Julian, if you agree that this needs to be fixed I would be glad if you'll add that in the next update of WPTools.
#1
♥ 0