Solved Synchronize 2 Combox

Superpat

Member
Local time
Today, 21:47
Joined
Aug 15, 2020
Messages
105
Hello,
I have a form with two combobox.
The combobox, lst_NomBase
Code:
SELECT DISTINCT [NomBase] FROM tblVariables   UNION SELECT  " Tous" AS NomBase FROM tblVariables
ORDER BY tblVariables.[NomBase];
Code:
Private Sub lst_NomBase_AfterUpdate()
      Dim sNewvar As Variant
      If Me.lst_NomBase = " Tous" Then                                         'TOUS
            Me.Filter = ""
            Me.Filter = False
            's_Bases = "*"
            'Lister_r_VariablesBases (s_Bases)
      Else
            Me.Filter = ""
            Me.Filter = False
            Me.Filter = "[NomBase] = '" & Me.lst_NomBase.Column(0) & "'"
            Me.FilterOn = True
            's_Bases = Me.lst_NomBase
            'Lister_r_VariablesBases (s_Bases)
            Me.lst_Module.Requery
            Me.Requery
      End If
End Sub


The combobox, lst_Module
Code:
SELECT DISTINCT tblVariables.Modules, tblVariables.NomBase  FROM tblVariables UNION SELECT " Tous",0  AS Modules FROM tblVariables
ORDER BY tblVariables.Modules;

With "Tous" =>"All", in the first combobox, It's good.
Tableau1.png


With selected name in lst_NomBase
Tableau2.png


I want the second in list has just the name concerning list
Tableau3.png

Can you help me ?
 

Attachments

Here you can see the example to show all records just clear the value in the related filter control.
 

Attachments

Thanks @CarlettoFed, its works, but what appens with "All". Perhaps an iif in "[Forms]![f_Variables]![lst_NomBase]", I try it but I cannot do.
 
Why do you prefix a combo name with lst ?
 
Thanks @CarlettoFed, its works, but what appens with "All". Perhaps an iif in "[Forms]![f_Variables]![lst_NomBase]", I try it but I cannot do.
I have a demo of a technique using TempVars, rather than hard-coded form references, to filter "ALL" or "One ID" selected from a table. Check it out. I know that TempVars are not universally liked. In this situation, though, I've found this technique quite easy to implement and very reliable.
 
I have a demo of a technique using TempVars, rather than hard-coded form references, to filter "ALL" or "One ID" selected from a table. Check it out. I know that TempVars are not universally liked. In this situation, though, I've found this technique quite easy to implement and very reliable.
Thanks @GPGeorge, I look that, for me it takes time.
 
Hello,
I move forward in my project,
It's near good. I added a function :
Code:
Public s_Modules As String
Public s_Bases As String

Public Function RendValeurBase() As String
      RendValeurBase = s_Modules
End Function

In lst_Module the code :
Code:
SELECT DISTINCT tblVariables.Modules, tblVariables.NomBase
FROM tblVariables
WHERE (((tblVariables.NomBase) Like RendValeurBase()));

It works perfectly, but I want to put " Tous", in first. I try :

Code:
SELECT DISTINCT tblVariables.Modules, tblVariables.NomBase  FROM tblVariables UNION SELECT " Tous",0  AS Modules FROM tblVariables
WHERE (((tblVariables.NomBase) Like RendValeurBase()))
ORDER BY tblVariables.Modules;

This code no longer works, I don't know why.
 

Attachments

Users who are viewing this thread

Back
Top Bottom