Order of events

I'm new to using FastReports, so this may have a simple solution that I just haven't found.

I have a report that prints a list of phone log entries. The possibilities are, calls from agent, calls to customer, and calls from agent to customer. I use a TfrxUserDataSet to supply the data to the field, and use a single field to supply either the agent name or customer name, controlled by my application. I have one TfrxMemoView on the report tied to this field. If the field has a value in it, I need that field to display, which is the default view. However, if the report is an "agent to customer" reports, my application supplies an empty string to the field. If the field is an empty string, I need to hide the MemoView and shift the remaining fields on the report to the left to fill in the gap. The following is my event handler for the OnBeforePrint of the MasterBand (Cust_AcctMgr is a variable linked to the name field).

procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
begin
if (<Cust_AcctMgr> = '') then
begin
LogListDataLogName.Visible := false;
LogListDataLogSubject.Left := 10.26;
LogListDataLogSubject.Width := 3.5;
LogListDataLogNotes.Left := 14.76
LogListDataLogNotes.Width := 12.0;
end
else
begin
LogListDataLogName.Visible := True;
LogListDataLogSubject.Left := 14.26;
LogListDataLogSubject.Width := 3.0;
LogListDataLogNotes.Left := 17.26
LogListDataLogNotes.Width := 8.5;
end;
end;

The problem is, when I load the report for an "agent to customer" log, nothing changes on the report. The MemoText is still visible, and nothing moves to the left. It appears as if the event is never fired, or that the name field is always empty when the event fires.

My question is, are the data fields of the TfrxUserDataSet populated before or after the OnBeforePrint event is fired for a report's band? If not, then checking a field's value is worthless in the OnBeforePrint event. Is there a way to tell if my event is even being executed?

Any help will be greatly appreciated. Thanks.

Comments

  • gpigpi
    edited 4:37PM
    Does your MasterData assigned with frxUserDataset?
  • edited 4:37PM
    Yes. It is called LogListData, and the field supplying the qualifying value is called LogName.
  • gordkgordk St.Catherines On. Canada.
    edited March 2017
    Have you written code at the delphi level for the userdataset's onfirst, onnext onprior and on eof events?

    objects are processed top down depending on band type
    and left to right in order of creation, possitional properties are in pixels
  • edited 4:37PM
    I let the TfrxUserDataSet default navigation do the work, and use TfrxUserDataSet.RecNo to decide the data to load. The report fills all the fields correctly, so the report works. It's only the event that doesn't seem to be working. When an empty string is passed in the LogName field, the report is unaltered. I want the report to hide the one MemoText and shift left the ones to the right so fill in the gap. I've been able to get the field to hide using the MemoText's conditional highlighting, but I can't move the other one's from there.

    I'm used to using breakpoints in my Delphi code when something is not working the way I expect, but there doesn't seem to be a way to do the same in my script, so I have no way of finding out if the event is even being fired.
  • gpigpi
    edited 4:37PM
    Create small demo project and attach it here or send to support@fast-report.com
  • edited 4:37PM
    Not a solution, but just an update.

    Since I am under a time constraint, I don't have a lot of time to work through this problem, so for now I decided to create a second report identical to the first, but with the indicated MemoText removed and the other fields modified. I let my Delphi code decide which report to show. Because the forms are essentially identical, they can both use the same userdataset, so my code is kept to a minimum.

    When I get the chance, I will look more closely at this.

    Thanks for working with me on this.
  • gpigpi
    edited 4:37PM
    Attach your report template (fr3)

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.