title: Access Subform Visibility
body: <p>I have an access form that contains a dropdown list of form names populated from a table. When someone selects a particular item from the dropdown I want to be able to display 1 of the corresponding subforms. For example, I have Form 1, Form 2, Form 3 in the dropdown. I select Form 2 and the subform two appears. I tried accessing the subforms visible property in VBA but got multiple errors and it never quite worked. Can anyone help?</p>
  
  <p>This is the code to populate the dropdown:</p>
  
  <pre><code>Private Sub Form_Load()
  
  Dim dba As Database
  Dim rst As Recordset
  Dim SQL As String
  
  Set dba = CurrentDb
  Set rst = dba.OpenRecordset("tbl_Forms", dbOpenDynaset, dbSeeChanges)
  SQL = "SELECT ListName FROM tbl_Forms"
  Set rst = dba.OpenRecordset(SQL, dbOpenDynaset, dbSeeChanges)
  
  Set rst = Nothing
  Set dba = Nothing
  End Sub
  </code></pre>
  
  <p>And for the subform visibility I tried:  </p>
  
  <pre><code>forms!mainform.Form1.visbile = false 
  forms!mainform.Form2.visbile = false
  forms!mainform.Form3.visbile = false
  
  Select case dropdown
  case 1 
  forms!mainform.Form1.visbile = true 
  forms!mainform.Form2.visbile = false
  forms!mainform.Form3.visbile = false
  case 2
  forms!mainform.Form1.visbile = false
  forms!mainform.Form2.visbile = true
  forms!mainform.Form3.visbile = false
  case 3 
  forms!mainform.Form1.visbile = false
  forms!mainform.Form2.visbile = false
  forms!mainform.Form3.visbile = true
  end select 
  </code></pre>