>Does anyone know how to build a field in a grid where there is no underlying field in a table? For example, if you had a Product Code field and wanted to show the product's description in the next column, but the grid's underlying table does not have a description field so the value must come from the product table. Since it is a grid, I will have many different product code/product description visible at once.
>
>Thanks in Advance,
>Sandi
Sandi,
Assuming your description table is open (only open, no need for set order, relation etc) :
-Add a grid column by increasing columncount (for description field). Adjust its columnorder to your taste.
-In column controlsource enter your expression :
(iif(seek(grdTable.proccode,'products','proccode'),products.description,''))
Where grdTable is alias of your grid's recordsource (with product code). Anytime proccode field changes, instantly description changes :)
PS: If you would assign the controlsource in code do not forget doublequotes. If your expression is wrong (ie: misspelling fieldname) you'd get a blank grid. This works with buffered, non-buffered. If your column is not the last column in grid you might want to code 'return .f.' into text1's 'when' (already readonly) to skip column when navigating in grid left-right.
Cetin