Solved Synchronize 2 Combox (1 Viewer)

Superpat

Member
Local time
Today, 11:51
Joined
Aug 15, 2020
Messages
96
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

  • ComboBox.accdb
    1.8 MB · Views: 72

CarlettoFed

Member
Local time
Today, 11:51
Joined
Jun 10, 2020
Messages
119
Here you can see the example to show all records just clear the value in the related filter control.
 

Attachments

  • ComboBoxNew.accdb
    448 KB · Views: 79

Superpat

Member
Local time
Today, 11:51
Joined
Aug 15, 2020
Messages
96
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.
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:51
Joined
Sep 21, 2011
Messages
14,301
Why do you prefix a combo name with lst ?
 

GPGeorge

Grover Park George
Local time
Today, 02:51
Joined
Nov 25, 2004
Messages
1,867
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.
 

Superpat

Member
Local time
Today, 11:51
Joined
Aug 15, 2020
Messages
96
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.
 

Superpat

Member
Local time
Today, 11:51
Joined
Aug 15, 2020
Messages
96
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

  • ComboBoxRenvoi.accdb
    720 KB · Views: 56

Superpat

Member
Local time
Today, 11:51
Joined
Aug 15, 2020
Messages
96
Thanks to all for your help, I finished my work, as I wanted.
 

Attachments

  • ComboBoxRenvoi3.accdb
    992 KB · Views: 71

Users who are viewing this thread

Top Bottom