Hi Experts,
I have an Access 2013 application. In my application, I open up an Excel spreadsheet, loop through values in a column and try to save those values to an Access table, but i get the following error:
Option Compare DatabasePrivate Sub Command3_Click() Dim xlApp As Object Dim xlWrk As Object Dim xlSheet As Object Dim i As Long Dim sql As String Set xlApp = VBA.CreateObject("Excel.Application") 'toggle visibility for debugging xlApp.Visible = False Set xlWrk = xlApp.Workbooks.Open("C:\ExcelImportFile.xls") Set xlSheet = xlWrk.Sheets("Sheet1") For i = 1 To 10 sql = "Insert Into tblTestImport (NOTE) VALUES (" & xlSheet.Cells(i, 2).Value & ")" DoCmd.RunSQL sql Next i xlWrk.Close xlApp.Quit Set xlSheet = Nothing Set xlWrk = Nothing Set xlApp = NothingEnd Sub
I changed NOTE to Notex, and added the single quotes around & xlSheet.Cells(i, 2).Value &.
That worked! But now every time it tries to save it prompt the following message:
How can I stop this from popping up?
thank you,
mrotor