title: Add or Update data from Excel to MYSQL
body: <p>I Have created a ODBC DSN to MySQL called "TEST". The table in the MySQL Database is Called "DETAILS" and the columns are called:</p>
  
  <pre><code>ID (Auto Number) | NAME | SURNAME | DATE|
  </code></pre>
  
  <p>In Excel, I have a userform with the following controls: Textbox1 = NAME, Textbox2 = SURNAME and DTPicker = DATE + a Command Button Called SAVE. </p>
  
  <p>Is there a way that I can save this data directly to the MySQL Database by pushing the command button? I have the ODBC DSN connection to access the database</p>
  
  <p>UPDATE</p>
  
  <p>This is the code I Have:</p>
  
  <pre><code> Private Sub CommandButton1_Click()
  Dim cn As ADODB.Connection
  Dim rs As ADODB.Recordset
  
  
  strCon = "Driver={MySQL ODBC 5.1 Driver};SERVER=SERVERNAME;DATABASE=DATABASE;UID=USERID;PWD=PASSWORD"
  
  Set cn = CreateObject("ADODB.Connection")
  
  cn.Open strCon
  Set rs = CreateObject("adodb.recordset")
  
  rs.Open "INSERT INTO MYTABLE (ID, Name, Surname, Date) VALUES (Textbox1.Value, Textbox2.value, DTPicker1.Value)", cn
  
  rs.Close
  
  End Sub
  </code></pre>
  
  <p>But It doesn't allow me to reference the CONTROLS, Textboxes and DTPicker</p>