Tuesday, March 18, 2014

Filtering on temp table

SETSELECTIONFILTER in temporary records
Regular record variables are looking at the actual table, so you can take the filter from one variable, copy them to another variable, and you get the same results, because the variable goes to the table and retrieves records from the physical table. No brainer right. You'd think that the same applies to temporary records right? Well that's where you are wrong, because temporary records don't have any values in them when you instantiate them, so when you fill only one of them, set filters, and copy the filters to the other one, it comes as no surprise that there are no values in there, BECAUSE IT DOESNT HAVE ANY VALUES.

You have a temporary record variable, which is empty when it is instantiated. You fill it up. Now it has records, temporary records that only exist in this memory space that is occupied by this single record variable. Now you apply a filter on this set of records. Now you want to apply the same filter to another temporary record, but you are surprised that you don't see anything in the other one. The other one hasn't been filed yet, it is uninstantiated!!! The second variable doesn't just read from the first variable, you have to actually put the records into the variable.

Think of a temporary record variable as a collection of objects. Rec (the temporary record variable that your form is based on) and NewRec (which is a global or local variable somewhere in your logic) are two different collections. One of them has been filled, but the other one has not been filled. The selectionfilter from Rec is properly applied to NewRec, but since there is nothing in there, you don't see anything.

No comments:

Post a Comment