I have a form that will show all the clients that I have. As I have many records I need to filter those records by alphabetical order. So, I thought that cascading comboboxes would be the solution. The first one would have the alphabet and the second one would have the records according with the letter chose.
So, if the cbofirst.letter is the first combobox, and the cbonome is the second, the following is my code so far:
Private Sub cbofirstletter_AfterUpdate()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim fletter As String
Set db = CurrentDb
Set rst = db.OpenRecordset("tblclientes", dbOpenDynaset)
Me!Cbonome = Null
If IsNull(cbofirstletter) Then
Me!Cbonome.Enabled = False
Me!Cbonome.Enabled = True
fletter = Me!cbofirstletter.Value
Me!Cbonome.RowSource = "SELECT fldnome " _
& "FROM tblclientes " _
& "WHERE fldnome Like " & fletter *
I can't make this work, and I think the problem is in the query statement. I have looked in several books and sites and I can't find the solution.
So, if you help me I would be glad. thank you in advance.
thank you MStef-ZG! I have looked into your file and it makes almost what I need. However, I wanted also to put an ALL on the first combo box, which would show all records in the second combobox. It only can be done on VBA right?