title: Passing value from the textbox to "TOP n" clause in SQL query
body: <p>I believe I have quite simple question, that would help me finish my project. I don't usually work with Access, but I was asked to help someone so here I am. </p>
  
  <p>My problem: I have a Form1 called "Start" in which there is a TextBox1 called "Kat1".
  I also have a SQL Query as:</p>
  
  <pre><code>SELECT TOP 3 tbl.Example FROM TABLE TBL
  </code></pre>
  
  <p>What I want to achieve is to let the user to write some number in "Kat1" so that Query returns this much top rows.</p>
  
  <p>I hope there is a way to this without using VBA, since my query is rather complicated, there are more textboxes, more subqueries with selecting top rows etc.</p>
  
  <p>I tried putting <code>SELECT TOP [Start]![Kat1]!Value</code> or simmilar. There maybe something wrong with my syntax or maybe this is all wrong and there is another way.
  Thank for help in advance.</p>
  
  <p><strong>Edit:</strong>
  For future readers ;) This is how I solved it with VBA:</p>
  
  <pre><code>Sub Query_Change()
  
  SQLstring = "SELECT TOP KAT1 col1 FROM TBL UNION SELECT TOP KAT2 col1 FROM TBL etc..."`
  
  CurrentDb.QueryDefs("MyQuery").SQL = SQLstring
  
  For i = 1 To 4
      SQLstring = Replace(SQLstring, "KAT" &amp; i, Forms!Start!("Kat" &amp; i).Value)
  Next i
  
  CurrentDb.QueryDefs("MyQuery").SQL = SQLstring
  End Sub
  </code></pre>
  
  <p>The code will run after user puts values into TextBoxes.</p>