title: Possible to change MS Access subform fields through VBA?
body: <p>I can find plenty of examples of how to return specific records in a subform through altering the underlying source query in code and re-querying, but I'm struggling to use the same principle to alter the fields that are returned.</p>
  
  <p>I have the following situation:</p>
  
  <p>Combobox to select 1 of 5 fields. Subform is supposed to show the selected field plus a couple of static fields, lets call them fields 6 and 7</p>
  
  <p>So in the case the user selects field 1 from the dropdown, subform should show fields 1, 6 and 7. In the case they pick field 4, subform should show fields 4, 6 and 7 etc.</p>
  
  <p>This is what (amongst other things) I've tried:</p>
  
  <p>Set the subform up through the wizard with a query (select field1, field6, field7) as source, amend said query after combobox selection is made:</p>
  
  <pre><code>Set qd = CurrentDb.QueryDefs("myqueryname")
  qd.SQL = "Select " &amp; mycomboboxselection &amp; ",field6,field7 from mytablename"
  Form_mymainformname.mysubformname.Requery
  </code></pre>
  
  <p>The query itself updates fine if I run that standalone after the change, but the subform within the main form doesn't change and when I click on the subform itself from the navigation window it seems to be stuck looking for field 1 as it asks me to input a parameter value</p>
  
  <p>Can anyone help with how to achieve this please?</p>