I am creating 2 combo boxes, where the possible selections of the second combobox need to depend on the selected part in the first combo box.
I use:
* Windows 10
* Access 2016
The code that I have used is:
Code:
Private Sub Combo269_AfterUpdate() Dim sTypeSource As String
sTypeSource = "SELECT [Type List].[ID], [Type List].[Brand], [Type List].[Type] " & _
"FROM [Type List] " & _
"WHERE [Brand] ='" & Me.Combo269.Value
Me.Combo290.RowSource = sTypeSource
Me.Combo290.Requery
End Sub
Where combo269 is the first combobox and Combo290 is the second.
The second combobox now doesn't give results. I already found what is causing this, but I can't find the solution.
With this code the result given in the combobox290
SELECT [Type List].[ID], [Type List].[Brand], [Type List].[Type] FROM [Type List] WHERE [Brand] ='Alfa Romeo
This needs to be:
SELECT [Type List].[ID], [Type List].[Brand], [Type List].[Type] FROM [Type List] WHERE [Brand] ='Alfa Romeo'
So only the ' at the end needs to be added to show good results. I tried to do this in the code with "'" behind "WHERE [Brand] ='" & Me.Combo269.Value
But this gives a syntax error. Anyone knowing what the correct part needs to be to solve this minor issue? I think it is something very very very simple but I can't nail it down.
Thanks in advanced for the help