Is it possible to show records in a temporary table in a subform? I know it is possible to open a new form by using FORM.RUNMODAL 50000,rRecord), But what if I want to update a subform instead of opening a new?
In your subform, define a global variable 'TempRec' record of the same table as Rec -- be sure to set the 'Temporary' property.
Define a function on the sub-form that will insert records into TempRec. The main form should call this function at the appropriate moments, when different records should show in the sub-form (possibly the OnAfterGetCurrentRecord trigger of the main form?).
Then, place the following code in the appropriate sub-form triggers:
Form - OnFindRecord(Which : Text[1024]) : Boolean
BEGIN
TempRec := Rec;
IF NOT TempRec.FIND(Which) THEN
EXIT(FALSE);
Rec := TempRec;
EXIT(TRUE);
END;
Form - OnNextRecord(Steps : Integer) : Integer
BEGIN
TempRec := Rec;
CurrentSteps := TempRec.NEXT(Steps);
IF CurrentSteps <> 0 THEN
Rec := TempRec;
EXIT(CurrentSteps);
END;
Warning: This example does not extend to 'Editable' sub-forms. More work is necessary in other form triggers to insure that insert/modify/delete operations occur on 'TempRec' rather than 'Rec'.
I've tried the same.
I made a form based on the table country.
Then I've declared a TempRec variable as record on the table country.
Then I set the temporary propriety to make it a temp table.
In the C/AL of my new form I've put your code in the 2 functions.
I then needed to create a new variable CurrentSteps and definied it as integer.
Put I only get a gray subform. Did I miss something or where could the problem be, that I don't get the data from the temp table in my subform?
Thanks for the code, still doesn't work.
I've now this code on my main form (not subform)
Form - OnOpenForm()
IF FIND('-') THEN
REPEAT
TempRec := Rec;
TempRec.INSERT;
UNTIL NEXT = 0;
Form - OnCloseForm()
Form - OnQueryCloseForm() : Boolean
Form - OnActivateForm()
Form - OnDeactivateForm()
Form - OnFindRecord(Which : Text[1024]) : Boolean
TempRec := Rec;
IF NOT TempRec.FIND(Which) THEN
EXIT(FALSE);
Rec := TempRec;
EXIT(TRUE);
Form - OnNextRecord(Steps : Integer) : Integer
TempRec := Rec;
CurrentSteps := TempRec.NEXT(Steps);
IF CurrentSteps <> 0 THEN
Rec := TempRec;
EXIT(CurrentSteps);
All the code needs to be done on the form where you want the records to be displayed (so all the codes needs to be on the subform). It looks like if you are using a mainform/subform.
No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
I'm using a form with a subform. I want to have it on the subform, but I don't have the 2 functions in the subform. do I've to create them in the subform?
It could also be a table box, I just need to get displayed a temporary table in a subform or a tablebox in a form.
I've read several posts. but I've never achieved doing it
I've achieved to make a form with a subform. I've made some little mistakes :-)
But it does write any changes I'm doing on the temp table directly in the original table.
In your subform, define a global variable 'TempRec' record of the same table as Rec -- be sure to set the 'Temporary' property.
Define a function on the sub-form that will insert records into TempRec. The main form should call this function at the appropriate moments, when different records should show in the sub-form (possibly the OnAfterGetCurrentRecord trigger of the main form?).
Then, place the following code in the appropriate sub-form triggers:
Form - OnFindRecord(Which : Text[1024]) : Boolean
BEGIN
TempRec := Rec;
IF NOT TempRec.FIND(Which) THEN
EXIT(FALSE);
Rec := TempRec;
EXIT(TRUE);
END;
Form - OnNextRecord(Steps : Integer) : Integer
BEGIN
TempRec := Rec;
CurrentSteps := TempRec.NEXT(Steps);
IF CurrentSteps <> 0 THEN
Rec := TempRec;
EXIT(CurrentSteps);
END;
Warning: This example does not extend to 'Editable' sub-forms. More work is necessary in other form triggers to insure that insert/modify/delete operations occur on 'TempRec' rather than 'Rec'.
Thanks, it works great after placing CurrForm.UPDATE to the function that fills the temporary record.
In your subform, define a global variable 'TempRec' record of the same table as Rec -- be sure to set the 'Temporary' property.
Define a function on the sub-form that will insert records into TempRec. The main form should call this function at the appropriate moments, when different records should show in the sub-form (possibly the OnAfterGetCurrentRecord trigger of the main form?).
Then, place the following code in the appropriate sub-form triggers:
Form - OnFindRecord(Which : Text[1024]) : Boolean
BEGIN
TempRec := Rec;
IF NOT TempRec.FIND(Which) THEN
EXIT(FALSE);
Rec := TempRec;
EXIT(TRUE);
END;
Form - OnNextRecord(Steps : Integer) : Integer
BEGIN
TempRec := Rec;
CurrentSteps := TempRec.NEXT(Steps);
IF CurrentSteps <> 0 THEN
Rec := TempRec;
EXIT(CurrentSteps);
END;
Warning: This example does not extend to 'Editable' sub-forms. More work is necessary in other form triggers to insure that insert/modify/delete operations occur on 'TempRec' rather than 'Rec'.
Thanks, it works great after placing CurrForm.UPDATE to the function that fills the temporary record.
Comments
Define a function on the sub-form that will insert records into TempRec. The main form should call this function at the appropriate moments, when different records should show in the sub-form (possibly the OnAfterGetCurrentRecord trigger of the main form?).
Then, place the following code in the appropriate sub-form triggers: Warning: This example does not extend to 'Editable' sub-forms. More work is necessary in other form triggers to insure that insert/modify/delete operations occur on 'TempRec' rather than 'Rec'.
I made a form based on the table country.
Then I've declared a TempRec variable as record on the table country.
Then I set the temporary propriety to make it a temp table.
In the C/AL of my new form I've put your code in the 2 functions.
I then needed to create a new variable CurrentSteps and definied it as integer.
Put I only get a gray subform. Did I miss something or where could the problem be, that I don't get the data from the temp table in my subform?
I hope someone can help me
thanks
You can write this code in the OnOpenForm-trigger.
I've now this code on my main form (not subform)
the subform is empty
I've these 2 variables (global) TempRec has the property temporary yes
Form property has as source table the table country
I'm sure I'missing something or didn't understand correctly[/code]
It could also be a table box, I just need to get displayed a temporary table in a subform or a tablebox in a form.
I've read several posts. but I've never achieved doing it
But it does write any changes I'm doing on the temp table directly in the original table.
TempSalesLine."Document no." := 'test' ;
TempSalesLine."Document type" := TempSalesLine."Document type"::Order;
TempSalesLine."Line No." := 1000;
TempSalesLine.insert;
FORM.RUNMODAL(0,TempSalesLine) ;
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Thanks, it works great after placing CurrForm.UPDATE to the function that fills the temporary record.
Thanks, it works great after placing CurrForm.UPDATE to the function that fills the temporary record.