Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Two recordsource in one grid.
Message
From
02/07/2001 09:06:17
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
02/07/2001 08:57:56
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00525830
Message ID:
00525839
Views:
19
>hi,
>can i place two field in one grid, while both the field are from different table, but they do have relation between them. Set the ControlSource of the column to the lookup function.

Yes, you can, but sometimes you may have trouble with information not being refreshed immediately. To avoid this, I often use a lookup function for this purpose (see below).

Another alternative is to use a view on both tables.

My lookup function:
**********************************************************************
FUNCTION MyLookup(tcAlias, tcOrder, txSeekValue, tcReturnValue, tlEmptyValues)
	* Search in another table. This function solves certain problems with VFP-relations
	* (the problem is that the user only sees new values after a TableUpdate()).
	* The parameter tcReturnValue should be passed as a string that will be evaluated
	* in the function.
	* If the fifth parameter is .T., the function returns an empty field (rather than null)
	*   if the record is not found.
	* For fast re-opening, the table is opened with a special alias, and remains open.

	local lnSelect, llFound, lcAlias
	lnSelect = select()
	lcAlias = tcAlias + "_mylookup"
	if not used(lcAlias)
		use (tcAlias) again alias (lcAlias) in 0
	endif
	select (lcAlias)
	set order to (tcOrder)
	llFound = iif(isnull(txSeekValue), .F., seek(txSeekValue))
	local lxReturnValue
	lxReturnValue = eval(tcReturnValue)	&& This will assign correct type, even if not found
										&& (and final result is NULL)
	if not (llFound or tlEmptyValues)
		lxReturnValue = NULL
	endif
	select (lnSelect)
	return lxReturnValue
ENDFUNC
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform