I have a drop-down list in a form that is used to select the first record associated with a letter. For example, if I select the letter A, all records starting with A will be displayed as a list in a control table provided for this purpose. It is therefore also a filter for the selected letter.
.
By default, this control table contains all records sorted alphabetically when the form is opened.
.
The drop-down list is dynamic. That is to say, it only contains the letters, symbols or numbers of the titles or names existing in the table linked to the main form. For example, if there is no title or name starting with Z, the letter Z does not exist in the drop-down list either.
.
The content type of the list is an SQL query ‘ql_TargetFS’ which looks like this:
SELECT DISTINCT "Target", "row_num" FROM ( SELECT '' AS "Target", 0 AS "row_num" FROM "TFilmsSeries" LIMIT 1 UNION ALL SELECT UPPER(LEFT("TitreAnglais1", 1)) AS "Target", MIN(r) AS "row_num" FROM ( S ELECT c1."English Title1", 1 + COUNT(c2."FilmSerieID") AS r FROM ( SELECT "FilmSerieID", "English Title1", UPPER("English Title1") AS u FROM "TFilmsSeries" ) c1 LEFT JOIN ( SELECT "FilmSerieID", "English Title1", UPPER("English Title1") AS u FROM "TFilmsS eries" ) c2 ON c1.u > c2.u OR (c1.u = c2.u AND c1."FilmSerieID" < c2."FilmSerieID")
GROUP BY c1."TitreAnglais1", c1."FilmSerieID"
)
GROUP BY UPPER(LEFT("TitreAnglais1", 1))
)
ORDER BY "Target" --
//
// Query for the [lst-Lettres] drop-down list in the [frm-FilmsSeries] main form.
// It generates a blank as the first element of the list and a list of the initial capital letters
// of the actor names in the [TFilmsSeries] table and associates with each letter the minimum line number
// among the actors whose names begin with that letter.
// The results are sorted alphabetically by initial capital letters.
// Dummy columns are used to handle sorting issues in embedded HSQLDB.
The dropdown list is also associated with the ‘Modified’ event and thus a Basic macro ‘MoveToTarget’. Here is the macro:
Sub MoveToTarget(oEvent As Object)
Dim oModel As Object, oForm As Object
Dim sFilter As String
oModel = oEvent.Source.Model
oForm = oModel.Parent
' Get the selected value from the drop-down list
sFilter = oEvent.Source.SelectedItem
' Apply the filter
If sFilter = "" Then
' If no letter is selected, display all records
oForm.Filter = ""
Else
' Apply the filter to display only records starting with the selected letter
oForm.Filter = "UPPER(""TitleAnglais1"") LIKE '" & sFilter & "%'"
End If
' Refresh the form to apply the filter
oForm.Reload()
End Sub
Actually, I would like the behavior when faced with the selection made in the list can react in two ways:
.
The first is as it is currently either: if I select a letter, the records are filtered and only the records corresponding to this letter are displayed. It works.
.
The second is that I would like all records to always be visible regardless of the selected letter and that the control table displays the first record associated with this letter.
.
I tried some things with control keys like, the Command key and shift, but the events linked to a drop-down list do not detect this kind of ‘Modifiers’ as for buttons for example.
.
Do some of the users have suggestions to obtain this double functionality for a drop-down list?