Language:


Creating a Report Generator Report - Adding a Search - Searching for Tags/Objects, Item Classifications, Contact Classifications and Persons

You can use the standard method described here to provide a search in almost any field. Three exceptions are the Tag/Object, Item Classification and Contact Classification fields, because these fields can contain several values separated by commas. The Salesman and Person fields in some registers can also contain several values separated by commas. For example, a particular Contact might belong to Classifications A, B and C, in which case its Classification field will contain "A,B,C". This Contact should be found when you search for Contacts belonging to Classification B, when you search for Contacts belonging to Classifications B and C, and so on. The standard search method will not find this Contact, because it is looking for field values that exactly match what is typed in the specification window. It is not capable of finding a field value that is only a partial match: it cannot extract the "B" or the "B,C" from "A,B,C".

If you need to search in a Tag/Object, Item Classification, Contact Classification or Person field, follow the steps listed below. In this example, we will describe placing a Classification variable in the report specification window, allowing the person producing the report to search for Contacts with a particular Contact Classification or Classifications:

  1. Return to the Report Definition record and go to the 'Input' card.

  2. Click the [Field] button. The 'Input Field' window opens. This window allows you to place a variable in the specification window, which the person producing the report will use to specify what they want to search for:

    Label
    Enter the name of the variable, as it will appear in the specification window. The Label should indicate to the person producing the report what they should type in to the variable.

    Variable Name
    Enter a name for the variable that will hold the search criterion (what will be searched for). Include at least one alpha character in the name and do not use spaces or punctuation marks of any kind. Use the underscore _ instead of a space. Ideally, the variable name should indicate the purpose of the variable.

    Type
    Paste Special    Variable Types
    Specify the type of the variable here. This will determine the type of information that can be held in the variable.

    In the example, the variable will contain the Classification that the person producing the report wants to search for. It should therefore be a string variable.

    For a list of the various types available, please refer to the Field and Variable Types page.

    Initial Value
    If you want a default value to be placed in the variable when the specification window opens, specify that default value here.

    Paste Register
    Paste Special    Registers in Standard ERP
    If you want the person producing the report to be able to use 'Paste Special' to bring a value into the variable, specify here the register whose contents are to appear in the 'Paste Special' list.

    It can be useful to enter a block here, rather than a register. Blocks are not included in the 'Paste Special' list attached to this field, but you can open a selection list of useful blocks by clicking the [Paste Window] button. The blocks in this list are:
    PerSClass
    Reporting Periods setting

    VATCodeSClass
    VAT Codes setting

    PasteCurDate
    opens 'Paste Date' window

    LandSClass
    Languages setting

    PMSClass
    Payment Modes setting
    For example, if you want the person producing the report to choose a VAT Code as a reporting criterion, click the [Paste Window] button and double-click "VATCodeSClass".

    Width
    Specify here in pixels how wide the variable should be when it is placed in the specification window. Ideally, the width should reflect the number of characters that should be entered in the variable. The default is -1, which means the variable will take up the entire width of the specification window, as shown in the illustration below.

    h, v
    Use these two fields to specify where you want the variable to be placed in the specification window. Enter co-ordinates (in pixels) for the top left-hand corner of the variable (not the label): h (horizontal) is the distance from the left-hand edge of the specification window, while v (vertical) is the distance from the top edge. Defaults are offered: they assume the usual Standard ERP vertical spacing of 20 pixels between variables.

    When the 'Input Field' dialogue box is complete, click the [OK] button to save it. The variable is added to the 'Input' card in the position specified in the h and v fields (in the example, 20 pixels below the existing vsCustNo variable). The 'Input' card shows you how the new variable will affect the appearance of the specification window:

  3. In our example. we placed the vsCategory and vsCustNo variables in the specification window using the [Selection] button on the 'Data' card and the 'Selection' dialogue box, as described here. This method both places a variable in the specification window and specifies the search that will take place when something is entered into that variable.

    However, the [Field] button on the 'Input' card and the 'Input Field' dialogue box only place a variable in the specification window, they do not also specify what will happen when something is entered into that variable. So, now you need to specify what will happen yourself. You need to specify that if the vsClass variable contains a value, there should be a search for Contacts whose Classification field contains a match or partial match for the contents of the vsClass variable. Remember that the automatic search for Contacts where CUType is 1 will remove any Contacts that are not Customers from the results.

    Change to the 'Data' card and click on the "Register" line in the report display area (marked "Register: Contacts..." in the example) to specify that the search is to be carried out in that register, and then click the [Print If] button. The 'Print If' dialogue box opens:

  4. Enter a Condition in the dialogue box as shown:

    SetInSet is a function inside Standard ERP that finds field values that partially or completely match the search criterion. This function takes two parameters (in the brackets separated by a comma) as follows:

    1. the variable from the specification window (named in step 2) containing the search criterion (vsClass in the example); and

    2. the field that is the subject of the search, vrContact.Classification in the example. This an expression meaning the Classification field in the Contact register. The expression is in two parts: the first part ("vrContact") is the name of the variable containing the Contact register. This name was given to the variable in the 'Register' dialogue box as described on the Specifying the Primary Register page. The second part ("Classification") is the internal name for the Classification field in the Contact register. The two parts are separated by a full stop. The expression "vrContact.Classification" therefore means "the Classification field in the Contact register". The expression is case sensitive, so you must use "Classification" and not "classification". You cannot refer directly to the Contact register itself in the expression: you have to refer to it indirectly by using the vrContact variable.

    This is the exact call to the SetInSet function in the example:

    SetInSet(vsClass,vrContact.Classification)

  5. When you click [OK] a "Print If:" line containing the condition is added to the Contact section of the report display area:

    For the person producing the report, there is no apparent difference between vsClass and the other two variables:

    When the specification window is open, if you press the Tab key a few times, the cursor will move through the variables in the order that was specified on the 'Data' card. "Print If:" lines will always be below "Selection:" lines on the 'Data' card. It is therefore recommended that you should place variables that you add to the specification window using the [Field] button underneath those that you add using the [Selection] button (as in the illustration above). This will ensure the insertion point will move from variable to variable in a logical manner when the user presses the Tab key.
We have used the SetInSet function in this description. This will allow the person producing the report to enter a number of Contact Classifications separated by commas. Contacts featuring all the Classifications listed will be shown in the report. For example, if they enter "1,2" in the specification report, Contacts with Classifications "1,2" and "1,2,3" will be shown in the report, but those with Classification "1" and those with those with Classification "2" will not.

An alternative to the SetInSet function is the SetInSet2 function. Use SetInSet2 if you need to allow extra flexibility when searching for Contact Classifications as follows:

1,2
Lists Contacts with Classifications 1 and 2 (including Contacts with Classifications 1, 2 and 3). (This search is also provided by SetInSet.)

1+2
Lists Contacts with Classifications 1 or 2.

!2
Lists all Contacts except those with Classification 2.

1,!2
Lists Contacts with Classification 1 but excludes those with Classification 2 (i.e. Contacts with Classifications 1 and 2 are not shown). Note the comma before the exclamation mark in this example.

!1,!2
Lists all Contacts except those with Classification 1 or 2 or both. Again, note the comma.

!(1,2)
Lists all Contacts except those with Classifications 1 and 2 (Contacts with Classifications 1, 2 and 3 will not be listed).

!1+2
Lists Contacts without Classification 1 and those with Classification 2 (Contacts with Classifications 1 and 2 will be listed).

(1,2)+(3,4)
Lists Contacts with Classifications 1 and 2, and those with Classifications 3 and 4.

1*
Lists Contacts with Classifications beginning with 1 (e.g. 1, 10, 100).

1*,!1
Lists Contacts with Classifications beginning with 1 but not 1 itself.

*1
Lists Contacts with Classifications ending with 1 (e.g. 1, 01, 001).

1*,*1
Lists Contacts with Classifications beginning and ending with 1.
Please follow the links below for more details about:
---

Go back to: