KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: An easy way of setting the default value of a Pop-up/Drop-down List
PRODUCT: 4D | VERSION: | PLATFORM: Mac & Win
Published On: January 14, 2000

Assuming that a Pop-up/Drop-down List is being used to display the contents of a field, there is an easy trick to setting the Pop-up to the correct value before the record is displayed. Using code like this:

If (Form Event = On Load)
pColor:=Abs(Find in array(pColor;[Table1]Color))
End if

This code will either set the pop-up to display the same value as the field or set the pop-up to display, by default, the first element of the pop-up. If the command Find in array finds the value of the field in the array, the pop-up will display the same value as the field. If the command Find in array does not find the value of the field in the array, the pop-up will return -1. The Abs (absolute value) command is used to convert -1 to 1, which results in the display of the first element in the pop-up.