another question about setselectionfilter

Dear All,
I am currently designing a new changes in a certain module. I just want to ask whether it is possible to fill a field in all lines in a certain form without using setselectionfilter ?
I will give example as follows:

Form/record A consists of 4 lines. there is a field named C and D. by using a commandbutton (cmd) in the form/record A, system will display form G (sourcetable F, F will be a source table in the 2 different forms) and one line in the form G, according to cursor placed by me or system. Then, by using commandbutton of form G, I can use one or two fields 0f one line in the form G allocated to the field C and or D that exists in the form/record A. (the forms/records I mean here are not in the obejct designer but actual application).
There is a coding in commandbutton of form G and also CU, that used in the process that is as follows:
CLEAR(CU# ***)
CU# ***.FFF(…,…,…,…);

CU#*** I defined in the tab variables of C/AL Global and datatype is codeunit.

I also want to know why I can’t find CurrForm and setselectionfilter in the CU…?

I would welcome to your answers and reply. tks a lot beforehand


Mark, you ask very strange questions! Why are you looking for CurrForm and SETSELECTIONFILTER in a… codeunit? [:O]

Wow, this is very difficult to understand, is it not possible to give a real example.

The currform is not available in a code unit because it is a form function as is setselectionfilter.

In a codeunit you would set filter/range on the table, you cannot cannot perform a form function within a codeunit you would have to call the function in the form after returning from the codeunit call.

Tks for your reply. What I mean that is if I can insert one data in a certain field of form A to a certain field of form B but consists of more than one line of item without selecting the line or without using setselectionfilter (from line # 10,000 to 30,000, or 40,000 - 50,000) but directly make it in the CU. I have guessed that it’s not possible, but I need more strengthening support or opinion/advise.

Hi JohnCon,

Tks for your answer. I have understood more clearly that in the CU I must set filter/range, what is the primary point in the coding if the CU will be used to execute a form (like tablebox) that its one of coding Setselectionfilter…?


Hello Mark,

let me try to make the SETSELECTIONFILTER story a little bit clearer.

The real purpose of this function WITHIN a form is to know which records are selected (so to speak).

A record is being selected by using Shift+Up/Down Arrow (current + next/previous record) or by pressing Ctrl+A (all records are selected) or by clicking the records with the Ctrl key pressed.

A good example for the usage is when you want to show a total for the slected lines only (like in Excel when you mark some fields containing values, the total sum of the selected cells will be shown in the status bar).

In this case you would code the following in OnAfterGetRecord:

ValueToDisplay := 0;
ValueToDisplay := ValueToDisplay + Rec2.Value;
UNTIL Rec2.NEXT = 0;

So the SETSELECTIONFILTER just sets a filter to the Rec2 variable making sure that the records in the result set of the filter set equals the records selected in the form.

If you need the selected records of a subform you need to create a function in the sub form with a record variable as parameter (VAR = True):

Procedure GetSelectedRecords(VAR GetRecs)
GetRecs := Rec2;
UNTIL Rec2.NEXT = 0;

After returning the control from the sub form you can call this function in the sub form with a temporary record and you will know which records have been selected in the sub form and now you can do all calculations you need and modify the current record of the calling form accordingly.

Hi Thomas,

You give me a clear understanding and I’ve actually understood then. I want to know also if it is possible for me to capture data in a field from a table or form (what I mean here the form/table is not being in the object designer but when it is run) and transfer it to a field in the other form that will spread it to all lines according ot selected lines. Meanwhile, the field DATA usually transferred to one line only in a certain table/form field. tks a lot.


Your request is a little bit confusing. Can you explain (based on a real example, not using AAA BBB and so on) what exactly you want to achieve ?

Dear Thomas, All,
I am still having no solution about setselectionfilter I asked.
I will describe moer detail then as follows:

  1. Tabel A
  2. Tabel B
  3. Tabel C
  4. Form A = table A (= means sourcetable of the form);
  5. Form B = table B (form B shows data in its matrix box, in the matrix box, there is a
    text box, in the right side (this form appearance is 100% as same as production forecast, the difference only located on
    the datas in the text box that can be chosen (1 data only according to preferred date). This text box is a Period Name
    field (its CU is PeriodFormMgt.CreatePeriodFormat(PeriodType,CurrForm.Matrix.MatrixRec.“Period Start”))) and commanded to
    be transferred to form A but it can transferred more than one data)
  6. Form C = table C

There is a command button in the form that if clicked will call form B. There is a command button, let say button M (push button) in the form that will transfer some datas of from some fields (let say field E, F and G (field E is not located in the text box and it is a code datatype field;field F and G are located in the text box column, field F is qty in the period G (G is a date))). If I chose a certain date (period) place cursor in a qty of a certain period (date), push the button M, then field E, F and G are automatically moved to form A (I’ve checked that the button has CU). Field E, F and G datas then exists in form A but in one line only according to filtered data in one line of form A.
The datas in the form A contains 10 lines (10000 - 100000) and I can move field E, F and G data to one line only, this is the 1st problem. If I want the button M moving the data to the 10 lines all at once after I select all the lines and dividing the qty in the field F to each lines (for example if it is 10, so each line will be 1), how to to that, I really don’t know. Or another alternative, I create a button in the form A that can split the field E, F and G data to the lines selected by me. For example a data/an entry in line 10000 has been filled, then I select line 20000 - 40000, after that push the button, and system automatically split the field E, F and G datas of entry/data existed in line 10000.
So, the options are two, I put some codings in form B or form A, which one is the best and not difficult. Pls let me know the solution for this problem. I will send you pm to tell what the forms’ actual names. Pls let me know your e-mail.
Once again, I appreciate for your kind attention. I really expected it.