Skip to content
Advertisement

Open form from listbox selection

I’m trying to open a form with a SQL condition set up from items selected in a listbox. I keep getting an error Syntax error in query expression. Which I don’t understand because if I create a new query and use the strSQL code it opens as designed. But using it to open a form just produces errors.

Advertisement

Answer

Only valid SQL WHERE clauses are to be used for whereCondition argument of DoCmd.OpenForm not a full SELECT query.

Consider concatenating the strDepartments into a proper WHERE condition.

Alternatively, open the form as is and dynamically adjust its RecordSource:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement