Perhaps you could set the sub form as Not enabled. Then put your validation code in the Main forms Before Update event and in the Main forms On Current event
Take a look at Conditional Formatting of Controls(textboxes etc)
You will be able to set the backround colour of controls dependent on the value of "Status"
If the values returned by the UDF are G2, -5, -7 then how would you like them ordered when the label is clicked.
-7 is smaller than -5, so -5 would be above -7, but where would you want the text value (G2) to be. Below -7 or above -5
Take a look at the attached db.
I have changed your UDF to return an integer rather than a variant which I believe solved the problem.
I have also changed the SQL statement used in the forms Recordsource so it no longer uses your UDF but does the calculation within the query instead.
Combo Products needs to be bound to the ProductID field.
The Row Source property needs to be changed to something like:
SELECT tblProducts.ProductID, tblProducts.ProductName FROM tblCategories INNER JOIN tblProducts ON tblCategories.CategoryID = tblProducts.CategoryID WHERE...
The Row Source property of the Product combo should be:
SELECT tblProducts.ProductName FROM tblCategories INNER JOIN tblProducts ON tblCategories.CategoryID = tblProducts.CategoryID WHERE...