ComponentOne Query 8.0
SetLookup Method

Syntax

C1QueryFrame.SetLookup(FullFieldName, DataSource, DataMember, ListField, ValueField, ShowListField, EditorType)

Notes

Method applies to C1QueryFrame control.

Arguments

FullFieldName is a string argument specifying the full dot-separated name of a folder field in a C1Query schema. (C1Query.PathSeparator is used instead of dot, if set by the programmer). Includes the field’s Name and the folder name(s) to which this field belongs, see Folders.

DataSource is an OLE DB/ADO data source to retrieve values from. It can be an ADO recordset, a ComponentOne True DataControl, a Visual Basic DataEnvironment, and so on.

DataMember is a string argument specializing the DataSource argument, if necessary. Some data sources, such as Visual Basic DataEnvironment, support multiple recordsets. In this case, it is required to specify a non-empty DataMember to select a particular recordset. For DataEvironment, it is a command name.

ListField is a string argument specifying the name of a recordset field used as the source of values shown to the user in the combo box list or menu. The user selects one of the ListField values.

ValueField is a string argument specifying the name of a recordset field used as the source of the value that is saved in the query item when the user makes a selection. This value is later used in SQL generation.

ShowListField is a Boolean argument that determines how the selected value is shown in the query item. If ShowListField=True, the control shows the ListField value. If ShowListField=False, the ValueField value is shown in the control.

EditorType is an enumerated value determining how the list is presented to the end user.

 

Constant Value and Name

Meaning

0 – c1qEditorMenu

The list is shown as a menu.

1 – c1qEditorComboEditable

The list is shown in the list portion of a combo box. The user can select from the list, and it is also possible to type the value directly in the edit box portion of the combo. This setting is available only if ValueField and ListField is the same field.

2 – c1qEditorComboNoneditable

The list is shown in the list portion of a combo box. The user can only select from the list.

Return Value

None

Description

This method retrieves a lookup list of values from a data source. After SetLookup call, values for the specified field (FullFieldName argument) become editable with selection of options (lookup list) in a combo box or menu, see Lookup Value Lists. The EditorType argument determines if it is a combo box or a menu.

Values are retrieved from the DataSource recordset (with optional DataMember specialization, if necessary). Values shown in the list are taken from the ListField recordset field. When the user makes a selection, the ValueField recordset field value is saved in the query item, to be used in SQL generation. Depending on the ShowListField argument, the string shown in the item after selection can be the ListField value (if ShowListField=True) or the ValueField value (if ShowListField=False).

This method is a “shortcut”; it helps you to specify lookup lists in one of the most common cases, when you have a lookup table in a database. In other cases, or if you need more control, use the LookupValues event.

See Also

Lookup Value Lists

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback