Selection in the drop-down list corresponding to criterion (1 Viewer)

Superpat

Member
Local time
Today, 06:31
Joined
Aug 15, 2020
Messages
96
Hello,
Can we sort the drop-down list: lst_CategoriesSousCat in alphabetical order
Thank you for your precious help.
 

Attachments

  • Essai_SousCat00.zip
    1,008.3 KB · Views: 84

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:31
Joined
Oct 29, 2018
Messages
21,474
Hi. Try using this Row Source.
SQL:
SELECT t_CatSsCat.SousCategorie, t_CatSsCat.ID_SsCat FROM t_CatSsCat ORDER BY t_CatSsCat.SousCategorie;
Does that help?
 

Superpat

Member
Local time
Today, 06:31
Joined
Aug 15, 2020
Messages
96
Hi. Try using this Row Source.
SQL:
SELECT t_CatSsCat.SousCategorie, t_CatSsCat.ID_SsCat FROM t_CatSsCat ORDER BY t_CatSsCat.SousCategorie;
Does that help?
Thanks theDBguy but it does not.
alpha1.jpg
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:31
Joined
Oct 29, 2018
Messages
21,474
Thanks theDBguy but it does not.
View attachment 86224
Ah, I guess that's not how I interpreted your original question/post. I thought you simply wanted to sort the listbox. Now, it seems you're asking to sort it using the textbox? Not sure I get it either.

Okay, I took a closer look and see that you were using code to set the Row Source for the Listbox. All I had to do was add the sort order to your code. This is what I see now.

1604001579543.png


Please see attached...
 

Attachments

  • Essai_SousCat00.zip
    1,007.2 KB · Views: 93

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:31
Joined
May 7, 2009
Messages
19,245
you may also try this.
see the Current event of the Main Form.
see additional textbox on Design view.
see the additional form-wide variable.
 

Attachments

  • Essai_SousCat00.zip
    1.3 MB · Views: 87

Superpat

Member
Local time
Today, 06:31
Joined
Aug 15, 2020
Messages
96
Thanks to you two.
I am picky and I apologize, I want a mixed of 2. Starting from that of arnelgp as a base, I want that by clicking in the lst_Categories list, the lst_CategoriesSousCat list is updated like that of theDBguy.
I copied the code, but it doesn't work.
Code:
Private Sub lst_Categories_AfterUpdate()
On Error GoTo Macro11_Err
   
    With CodeContextObject
'        DoCmd.SearchForRecord , "", acFirst, "[Categorie] = " & "'" & Screen.ActiveControl & "'"
'        .lst_CategoriesSousCat.RowSource = "SELECT [SousCategorie],ID_SsCat FROM t_CatSsCat where CategorieFK = " & .lst_Categories.Column(1)
        DoCmd.SearchForRecord , "", acFirst, "[Categorie] = " & "'" & Screen.ActiveControl & "'"
        .lst_CategoriesSousCat.RowSource = "SELECT [SousCategorie],ID_SsCat FROM t_CatSsCat where CategorieFK = " & .lst_Categories.Column(1) & " order by souscategorie"
    End With
Debug.Print CurrentRecord

Macro11_Exit:
    Exit Sub

Macro11_Err:
    MsgBox Error$
    Resume Macro11_Exit
End Sub
 
Last edited:

cabete

New member
Local time
Today, 05:31
Joined
Feb 24, 2011
Messages
4
Dont know if help or not, see this attach
 

Attachments

  • ComboBoxesEmCascata.mdb
    736 KB · Views: 92

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:31
Joined
May 7, 2009
Messages
19,245
i have not open dbg's db.
but check if this is the same in your mind.
 

Attachments

  • Essai_SousCat00.zip
    1.2 MB · Views: 81

Superpat

Member
Local time
Today, 06:31
Joined
Aug 15, 2020
Messages
96
i have not open dbg's db.
but check if this is the same in your mind.
Thank you arnelgp, that's exactly what I wanted, you guessed my wishes.
Now do I need to create a new topic to check for duplicates in the subcategory (linked with the corresponding category).
thank you cabete for your example.
 

Users who are viewing this thread

Top Bottom