Hi Randy,
Thank you for your reply. Please see my answer to your questions:
Your records all have them....or not (new records)! only existing records have the primary key not the new record. The table has a AutoNumber primary key, which will be generated once record is added to the table (not at collection level).
You also need to implement either another collection for deletes, or anther column in your collection to indicate a delete. So you mean once I am removing the record from this collection, it should get added to another collection (includes all the deleted record from current collection), correct?
Now...one question that I have - what is the relationship of the gallery to the form above it?
You are mentioning that the user can click on "Update", but I am not seeing that in your picture. Is Update where you submit the form? The form is connected to the table (top section of the picture) only to do the validation for required field, but when user click Add button, I have below code:
Collect(
tmp_CSDCalculator,
{
'From Date': DateValue4.SelectedDate,
'To Date': DateValue3.SelectedDate,
Notes: DataCardValue3.Text,
Percentage: Value(DataCardValue4.Text),
In: DataCardValue5.Selected.Value,
NumberOfDays: If(
!IsBlank(DateValue4.SelectedDate) && !IsBlank(DateValue3.SelectedDate),
DateDiff(
DateValue4.SelectedDate,
DateValue3.SelectedDate
) + 1,
0
),
NumberOfWeeks: If(
!IsBlank(DateValue4.SelectedDate) && !IsBlank(DateValue3.SelectedDate),
Round(
(DateDiff(
DateValue4.SelectedDate,
DateValue3.SelectedDate
) + 1) / 7,
1
),
0
),
NumberOfDayToInclude:0,
'Employee ID': varEmployeeID
}
);
And, the gallery is connected to the tmp_CSDCalculator collection. The Update button is below the gallery and has some code as below which is not correct and need to be change (the code works perfect in my Create page and is not right for Edit page):
ForAll(
tmp_CSDCalculator,
Patch(
'CSD Calculators',
Defaults('CSD Calculators'),
{
'From Date': ThisRecord.'From Date',
'To Date': ThisRecord.'To Date',
Notes:ThisRecord.Notes,
Percentage: ThisRecord.Percentage,
In: ThisRecord.In,
NumberOfDays:Value(txt_NumberOfDays.Text),
NumberOfWeeks:Value(txt_NumberOfWeeks.Text),
NumberOfDayToInclude:Value(txt_DaysToInclude.Text),
'Employee ID':varEmployeeID
}
)
);
Please let me know if you need more detail.
Thanks 🙏