How to insert values into the database table using VBA in MS access

后端 未结 3 752
自闭症患者
自闭症患者 2020-12-18 07:37

I\'ve started to use access recently. I am trying to insert a few rows into the database; however, I am stuck as it is throwing an error:

Too few par

3条回答
  •  难免孤独
    2020-12-18 08:03

    1. Remove this line of code: For i = 1 To DatDiff. A For loop must have the word NEXT
    2. Also, remove this line of code: StrSQL = StrSQL & "SELECT 'Test'" because its making Access look at your final SQL statement like this; INSERT INTO Test (Start_Date) VALUES ('" & InDate & "' );SELECT 'Test' Notice the semicolon in the middle of the SQL statement (should always be at the end. its by the way not required. you can also omit it). also, there is no space between the semicolon and the key word SELECT

    in summary: remove those two lines of code above and your insert statement will work fine. You can the modify the code it later to suit your specific needs. And by the way, some times, you have to enclose dates in pounds signs like #

提交回复
热议问题