Error in cascading Combo Boxes
Hi Access community,
In a form, I’d like to filter choices in combo box cobStatus based on the value I select in combo box cobCountry. The code I copied from an online post is:
Private Sub cobCountry_AfterUpdate()
Dim strSQL As String
strSQL = “SELECT [Tables]![Project Database].[Project Stage]” & _
“FROM [Tables]![Project Database]” & _
“WHERE [Tables]![Project Database].Country = ” & Me.cobCountry & _
“ORDER BY [Tables]![Project Database].[Project Stage];”
Me.cobStatus.RowSource = strSQL
Me.cobStatus.Requery
End Sub
So, I select a country in cobCountry but, when selecting cobStatus an alert pops us:
‘Syntax error in FROM clause’
As I said, I copied the code from a demo database a user shared online and in his demo database the code works. The only difference btw my DB and his is that he’s pulling values from two separate tables (tblCountry and tblStatus), whereas I am pulling data from a single table. May that be the issue?
Thanks for any help you can provide!
Hi Access community, In a form, I’d like to filter choices in combo box cobStatus based on the value I select in combo box cobCountry. The code I copied from an online post is: Private Sub cobCountry_AfterUpdate()Dim strSQL As StringstrSQL = “SELECT [Tables]![Project Database].[Project Stage]” & _”FROM [Tables]![Project Database]” & _”WHERE [Tables]![Project Database].Country = ” & Me.cobCountry & _”ORDER BY [Tables]![Project Database].[Project Stage];”Me.cobStatus.RowSource = strSQLMe.cobStatus.RequeryEnd Sub So, I select a country in cobCountry but, when selecting cobStatus an alert pops us: ‘Syntax error in FROM clause’ As I said, I copied the code from a demo database a user shared online and in his demo database the code works. The only difference btw my DB and his is that he’s pulling values from two separate tables (tblCountry and tblStatus), whereas I am pulling data from a single table. May that be the issue? Thanks for any help you can provide! Read More