run time error 3061 - too few parameters. expected 3

Erick

Active Member
Joined
Feb 26, 2003
Messages
362
Can anyone spot what is where I am going wrong with this code. It is coming up with 'run time error 3061 - too few parameters. expected 3' error.

It is just supposed to create a table (which it appears to be working fine) and then insert some simple data into it.

Code:
Sub Temp()    Dim MyDB As DAO.Database
    Set MyDB = CurrentDb()
    
    MyDB.Execute "CREATE TABLE tempTable (F1 STRING, F2 INTEGER, F3 STRING, F4 STRING);"
    MyDB.Execute "INSERT INTO tempTable (F1, F2, F3, F4) Values (a, 0, b, c)"
End Sub

Greatly appreciate all your help in advance
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Which line throws back the error?

I see one thing I think may be wrong. If a,o,b,c are literal text values, they need text qualifiers, i.e. maybe something like:
Code:
MyDB.Execute "INSERT INTO tempTable (F1, F2, F3, F4) Values ('a', '0', 'b', 'c')"
Note. You may have other errors too. I have not used this method to create DAO temp tables. I am just pointing out something that sticks out to me.
 
Upvote 0
Thanks for the reply Joe.

It was just as simple as text qualifiers as you pointed out. Sometimes it's those simple things that trip me up because I was looking for a more complex solution.:rolleyes:

Thanks again
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top