Language:


Searching for Records within a Period

It will often be necessary to provide a search for records that fall within a certain period. For example, you might want to produce a list of Invoices from a particular period. Follow these steps:
  1. Create a new report. On the 'Data' card, specify that the Invoice register is to be the primary register. On the 'Layout' card, design the output of the report as required.

  2. To add the period search, return to the 'Data' card and click on the line in the report display area marked "Register: Invoices..." to specify that the search is to be carried out in the Invoice register. Click the [Selection] button and complete the 'Selection' dialogue box as illustrated below:

    This places a variable named vsPeriod in the specification window where the user can enter the required period (start and end dates separated by a colon). The formula to be applied to vsPeriod is as follows:
    vrInvoice.InvDate>=StringToDate(FirstInRange(vsPeriod,10)) and vrInvoice.InvDate<=StringToDate(LastInRange(vsPeriod,10))
    The FirstInRange function calculates the first date of the period by extracting the text before the colon from vsPeriod. Similarly, LastInRange extracts the text after the colon. FirstInRange and LastInRange take a second parameter, which is always 10 (the maximum number of characters including separators contained in a date). vsPeriod is a string variable, so the results of both FirstInRange and LastInRange are also strings. StringToDate converts the strings to dates. There is then a search for Invoices whose Invoice Date is later than or equal to the start date of the specified period, and earlier than or equal to the end date.

    To help the user choose a report period, specify PerSClass as the Paste Register. This will attach a 'Paste Special' list to the vsPeriod variable in the specification window, showing the contents of the Reporting Periods setting. As the Reporting Periods setting is a block, it is not included in the 'Paste Special' list attached to the Paste Register field.