Question : Trouble inserting date into Access 2003 database from Excel VBA using SQL

I can't seem to insert a date field into an Access 2003 database.  I have added a reference to 'Microsoft DAO 3.6 Object Library'.  I have tried every date format under the sun.  The code works fine with string data.  Any suggestions would be appreciated.  Here is a simplified version of the code.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
Const dbPath As String = "C:/Projects/TTdb.mdb"
    
    Dim dbTT As DAO.Database
    Dim strSQL As String
    Dim ws As Worksheet
   
    ' Open database connection
    Set dbTT = OpenDatabase(dbPath)
 
    strSQL = "INSERT INTO Timesheet ( Date, Employee ) VALUES ( #04/21/2009# , 'Name' );"
    
    dbTT.Execute strSQL
       
    ' Close database
    dbTT.Close
    Set dbTT = Nothing

Answer : Trouble inserting date into Access 2003 database from Excel VBA using SQL

Hi

Are you sure your Date field is named Date as this is a reserved word in Access.  Your code otherwise works absolutely fine for me (with a date field with a different name).

Richard
Random Solutions  
 
programming4us programming4us