Form ComboBox Acting As Table Column Header In Access 2007 Query -


i have form unbound combobox has column headings table dbo_orderheader. want use combobox field act table column header instead of hard coding specific table column header, way user can search dynamically form on column choose instead of having huge list of search boxes each table column.

please can on way in access query? using access 2007.

thanks.

see picture attached

i'm pretty sure there's no way imbed form reference column heading in static query design, use code behind form dynamically update query design , open query, this

private sub btnopenquery_click() dim cdb dao.database, qdf dao.querydef const queryname = "flexquery"  set cdb = currentdb docmd.close acquery, queryname, acsaveno on error resume next docmd.deleteobject acquery, queryname on error goto 0 set qdf = cdb.createquerydef(queryname, _         "select urn, styleno, [" & me.combo3.value & "] " & _         "from dbo_orderheader " & _         "where [" & me.combo3.value & "]=""" & me.text5.value & """" _     ) set qdf = nothing set cdb = nothing docmd.openquery queryname, acviewnormal end sub 

note: sample code assumes "dynamic" column text column, puts " characters around text5.value when constructing sql statement. code have enhanced handle other column types (e.g., no quotes numeric columns, , perhaps # delimiters dates).


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -