title: VBA: Robust Database creation
body: <p>i find this code, when trying to create db, using adodb and adox. </p>
  
  <p><a href="http://www.vb-helper.com/howto_ado_create_table.html" rel="nofollow">Here you can check original, it is the same. Thanks for author</a></p>
  
  <pre><code>Private Sub Command1_Click()
  Dim db_file As String
  Dim conn As ADODB.Connection
  Dim rs As ADODB.Recordset
  Dim num_records As Integer
  
  ' Get the database name.
  db_file = App.Path
  If Right$(db_file, 1) &lt;&gt; "\" Then db_file = db_file &amp; _
      "\"
  db_file = db_file &amp; "People.mdb"
  
  ' Open a connection.
  Set conn = New ADODB.Connection
  conn.ConnectionString = _
      "Provider=Microsoft.Jet.OLEDB.4.0;" &amp; _
      "Data Source=" &amp; db_file &amp; ";" &amp; _
      "Persist Security Info=False"
  conn.Open
  
  ' Drop the Employees table if it already exists.
  On Error Resume Next
  conn.Execute "DROP TABLE Employees"
  On Error GoTo 0
  
  ' Create the Employees table.
  conn.Execute _
      "CREATE TABLE Employees(" &amp; _
          "EmployeeId INTEGER      NOT NULL," &amp; _
          "LastName   VARCHAR(40)  NOT NULL," &amp; _
          "FirstName  VARCHAR(40)  NOT NULL)"
  
  ' Populate the table.
  conn.Execute "INSERT INTO Employees VALUES (1, " &amp; _
      "'Anderson', 'Amy')"
  conn.Execute "INSERT INTO Employees VALUES (1, 'Baker', " &amp; _
      "   'Betty')"
  conn.Execute "INSERT INTO Employees VALUES (1, 'Cover', " &amp; _
      "   'Chauncey')"
  ' Add more records ...
  
  ' See how many records the table contains.
  Set rs = conn.Execute("SELECT COUNT (*) FROM Employees")
  num_records = rs.Fields(0)
  
  conn.Close
  
  MsgBox "Created " &amp; num_records &amp; " records", _
      vbInformation, "Done"
  End Sub
  </code></pre>
  
  <p>But how to make it more robust, so, i don't want to delete db.</p>
  
  <p>How to check, if db exists and if db.tables contains my table? </p>
  
  <p>additional question: am i right, that this code create db for ms-access 2007?</p>
  
  <p>Thanks for help!</p>