title: Insert Query with Foreign Key
body: <p>I have three tables in a database and they are interlinked to each other with foreign keys. I want to do a INSERT query so that I can enter the data. I can insert data to each tables individually but when using foreign key constraint I am getting errors.Here are table relationship and VBA form through which i am trying to enter the data
  <a href="http://i.stack.imgur.com/0R6Al.jpg" rel="nofollow">VBA Form</a>,<a href="http://i.stack.imgur.com/9HZL8.jpg" rel="nofollow">Relationships &amp; Data Types</a></p>
  
  <p>I am using these two queries as of now but the second one is throwing errors.</p>
  
  <pre><code>sql = "insert into T1(ID,FName,Email)values('" &amp; TextBox1.Text &amp; "', '" &amp; TextBox2.Text &amp; "','" &amp; TextBox3.Text &amp; "')"
  sql = "insert into T2(ID,PhoneNumber,City) Values (Select(ID FROM T1 WHERE FName=" &amp; TextBox2.Text &amp; "),'" &amp; TextBox4.Text &amp; "','" &amp; TextBox5.Text &amp; "')"
  </code></pre>
  
  <p>Please note ID is the main field in my tables and I am to do search,update and delete with that field</p>