you cannot dereference a combobox's value into a SQL statement like that; that portion of a SQL statement does not allow for expressions.One option is to use VB code to dynamically create a sql statement and concatenate the value of the combobox into the string, and then assign that sql statement to the object that needs it, whenever the combobox value changes.For example, on the AfterUpdate() event of your combo box, you'd do something like this:Private Sub YourCombo_AfterUpdate() Dim SQL as String If Isnull(YourCombo) Then Exit Sub SQL = "Select tblCompany.CompanyName, tblCompany." & YourCombo.Value & ", tblClients.ClientName, " ' .... etc ...... ' Assign the SQL string to whichever object needs it changed: SomeControl.RecordSource = SQL ' And be sure to requery that object: SomeControl.RequeryEnd Sub
Alternatively, if your combo has only 5 set values that cannot change, you can use an IIF() function in your query to dynamically choose the column to pull from, and this does not require building SQL strings or changing the properties of object through code, you can keep it static:SELECT tblCompany.CompanyName, IIF(CboSearchDesc = 'Column1', tblCompany.Column1, IIF(CboSearchDesc = 'Column2', tblCompany.Column2, IIF(CboSearchDesc = 'Column2', tblCompany.Column3, IIF(CboSearchDesc = 'Column2', tblCompany.Column4, Column5) ) ) ) as Result, tblClients.ClientName, ..etc...FROM ...etc...
- Jeff