title: "Compile Error: Only Comments may appear after End Sub, End Function.." Access 2010 VBA
body: <p>I am creating a form and I have created my first function in the VBA window.  The function creates Buttons.  After I type anything after the 'End function' I get an error- "Only comments appear after .."  What's wrong?  Am I putting the function in the wrong area?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>Option Compare Database 
  Option Explicit
  
  Function MainMenuOptions()
  
  Dim frm As String
  frm = "Main"
  
  Dim SCFormB As Control
  Dim SCSearchB As Control
  Dim SCReportB As Control
  
  Set SCFormB = CreateControl(frm, acOptionButton, , , , 0.5, 0.6, 1.5, 0.55)
  Set SCSearchB = CreateControl(frm, acOptionButton, , , , 0.5, 1.5, 1.5, 0.55)
  Set SCReportB = CreateControl(frm, acOptionButton, , , , 0.5, 2.4, 1.5, 0.55)
  
  
  End Function
  </code></pre>