title: MS Access - Date as Table Field Name
body: <p>I need to create a table in MS Access, then append columns with DATES as the field names based upon a user-provided date range (StartDate, EndDate), like this:</p>
  
  <p>LastName | FirstName | Role | 10/01/2017 | 10/02/2017 | ....</p>
  
  <p>The following snippet comes close, but can only use dates formatted as "Oct01" (mmmdd), vs the desired "10/01/2017".  I swear my earliest attempts did produce the desired date format as the field name, but I cannot seem to reproduce - guessing a syntax issue on "format";</p>
  
  <pre><code>Dim db As Database
  Dim StartDate As Date
  Dim EndDate As Date
  Dim strDate As String
  
  Set db = CurrentDb
  
  StartDate = #10/1/2017#
  strDate = Format(StartDate, "mmmdd")
  
  db.Execute "CREATE TABLE MyTable " &amp; _
      "(LastName CHAR, FirstName CHAR, Role CHAR);"
  db.Close
  
  CurrentDb.Execute "ALTER TABLE myTable ADD COLUMN " &amp; Format(StartDate, "mmmdd") &amp; " CHAR"
  
  StartDate = StartDate + 1
  
  CurrentDb.Execute "ALTER TABLE myTable ADD COLUMN " &amp; Format(StartDate, "mmmdd") &amp; " CHAR"
  
  ...
  </code></pre>