When I run the following code, I receive syntax error with INSERT INTO statement. Prior to executing the DoCMD step, the locals window shows the value of valuestring to be a string with a value of "1/4/2016"
I assume the error has to do with a string being entered into a date field, but not sure how to fix it.
Formdate is formatted as a date and data1 is not declared, though it shows up properly in the locals window as a date, #1/4/2016#
Public Sub Import2(FileName As Variant)
Dim wb As Object, ws As Object
Dim xl As Object
Set xl = CreateObject("excel.Application")
Dim qs As String
Dim ValueString As String
'opens workbook, populates data1, etc.
Set wb = xl.Workbooks.Open(FileName)
Set ws = wb.worksheets("For Export")
data1 = ws.cells(2, 1)
Data2 = ws.cells(2, 2)
Data3 = ws.cells(2, 3)
ValueString = "(" & data1 & ")"
qs = "INSERT INTO MAF (FormDate) VALUES & valuestring"
DoCmd.RunSQL qs
'CurrentDb.Execute qs