How Do I Make the Task Position on a Certain Record When it Starts? (Magic xpa 3.x)
![](/PublicKnowledge/servlet/rtaImage?eid=ka2D0000000ThWP&feoid=00ND0000005rAjf&refid=0EMD0000000JHgT)
Sometimes you will want to show an entire list of items, but you want the user positioned on one record. For instance, in this example, when the user double-clicks on a field that already specifies a DVD title, they will be positioned on that title.
This is accomplished in Magic xpa by using the Locate property. Whereas the Range property will restrict the number of records that are displayed, the Locate property just changes which record is current.
![](/PublicKnowledge/servlet/rtaImage?eid=ka2D0000000ThWP&feoid=00ND0000005rAjf&refid=0EMD0000000JHgX)
-
In the Data View, go to the Column that you will be positioning on. In this example, we are working with the serial number (SN) field, attempting to locate on the first DVD where the serial number matches the serial number passed in as a parameter.
-
Press Alt+Enter to go to the Column Properties, and find the Locate from property.
-
Zoom from the Locate From field (or press fx) to enter an expression. This expression will represent the data you are trying to locate on.
Now, when the program opens, it will attempt to position on the first record that matches the Locate expression. If the record isn’t found, it will position on the next record.
The default setting of Locate Order is Ascending. So in our example, the search went from the top of the list to the bottom. We used the Locate from property to position on the first record found that matched the criteria.
However, if we had set (Ctrl+R) Range/Locate->Expressions->Locate Order to Descending, then the search would have proceeded from the bottom of the list on up. In this case, we would have had to set the criteria in the Locate from property.
If you enter a Locate from and a Locate to, then if the record is not found, the user gets an error message “Record not found - positioned at beginning”.
If you would like to use a Boolean expression to match a record, you can enter it in Range/Locate->Expressions->Locate Expression. This works very similarly to a Range expression, which is discussed in Using a Range Expression.
![](/PublicKnowledge/servlet/rtaImage?eid=ka2D0000000ThWP&feoid=00ND0000005rAjf&refid=0EMD0000000JHgV)
By default, the current record will show up at the top of the window. Sometimes this confuses the user, who may think that there are no other records above. However, if you set Options->Settings->Environment->Center Screen in Online to Yes, then the current record will appear in the middle of the window, as shown here.
The Online and Rich Client Samples projects (program DV07 and RDV07)