View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Alan Alan is offline
external usenet poster
 
Posts: 152
Default Excel to Access SQL problem

Hi, I am trying to use a SQL string using INSERT INTO to populate a table in
Access.
This works fine for all text based columns but returns a runtime error for
columns with numbers. I have tried omitting thew single quotes but am still
having no luck.
Can someone help..please.
The code I'm using is below;
ReDim myfield1(LBound(myfield1) To UBound(myfield1), 1 To 4)

For x = LBound(myfield1) To UBound(myfield1)
For y = 1 To 4
myfield1(x, y) = mysheet.Cells(x + 1, y).Value
Next y



mysql = "INSERT INTO Backups(Client,Policy,Schedule,Media) "
mysql = mysql + "VALUES ('" & myfield1(x, 1) & "','" & myfield1(x, 2) &
"','" & myfield1(x, 3) & _
"','" & myfield1(x, 4) & "') "


command.CommandText = mysql
MsgBox mysql
command.Execute