Alright, no problem. I'll try and explain as much as possible.
So you want to dynamically add and remove an item in your collection.
To put it shortly, "Collect()" create a new item whereas "RemoveIf()" delete an existing item. Assuming your "Name"-column is the identifying key, the code will look like this:
Collect(colTabs, {Name:"Tab"})
RemoveIf(colTabs, Name = "Tab"})
"RemoveIf()" gives a wider scope compared to "Remove()" and efficiently deletes ALL items corresponding to the given name, thus deleting possible duplicates.
Now to call those two functions, you will need to write some code in "OnChange" property of your controls.
"OnChange" is a property which is triggered everytime the value of the control is changed. For a text input, it is triggered when you change the text. For a check box, it is triggered when you check/uncheck it.
Assuming you've stored your tab's name inside "colSourceData", you will put the code below in the "OnChange" property of your checkbox:
If(Self.Value,
Collect(colTabs, {Name:ThisItem.Name}),
RemoveIf(colTabs, Name = ThisItem.Name)
)
Using "Self", the code will ask the parent control (the checkbox) about its value. If it's TRUE, it will create a new item using "ThisItem" which refer to the currently selected record of the collection. So to say, we're extracting the "Name" in "colSourceData" and create an item in "colTabs" with it.
Otherwise if it's FALSE, "RemoveIf()" will delete any record whose "Name" is equal to the name of the unchecked item.
Now to check if the selected value in your combo box starts with "SNOW". As I said earlier, you can use "StartsWith()" to check if a string starts with a text sample.
To add/remove an item depending if the selected value does start with "SNOW", add the code below in the "OnChange()" of your combo box:
If(StartsWith(Self.Selected.Value, "SNOW"),
Collect(colTabs, {Name:"SNOW"}),
RemoveIf(colTabs, Name = "SNOW")
)
Everytime you change the value of the selected item in your combo box, it will now check if its text starts with "SNOW" and then execute the appropriate function.
As for your second condition, it will require a simple little trick. Everytime your collection is changed, you need to check if it's empty. If it is, you create the new item "Other service".
However, a collection does not have a "OnChange" property. That's why you have to add this code everytime you've added/removed an item in your collection:
...
If(IsEmpty(colTabs),
Collect(colTabs, {Name:"Other Services"}),
RemoveIf(colTabs, Name = "Other Services")
)
This will check if your collection is empty, and add/remove the "Other Services" tab to correspond to the situation.
This is a quickly-thought solution, there may be some hidden mistakes there and there. Please try and see how it goes, I hope my answer was clear enough.