Error 3061

A

Alain

Hi, I need a little help with the Update syntax, I need to update multiple
fields but always get the error 3061 Too few parameters, expected 2

CurrentDb.Execute _
"UPDATE tblLease Set AreaLand = " & Me.AreaLand & "[,AreaLandSM = " &
Me.AreaLandSM & "] WHERE IdLease = " & num2 & ""
Can anyone explain to me what is wrong here, I am following the example
from Access books

PS using Access 2000

TIA

Alain
 
A

Allen Browne

If Access finds any name that it does not recognise, it assumes it must be a
parameter. It typically means a field name has been spelled wrongly, or
there is something wrong with the SQL statement.

Assuming you have 3 Number type fields, and that all 3 have values in your
form (are not null), try this:

Dim strSql As String
strSql = "UPDATE tblLease SET AreaLand = " & Me.AreaLand & _
", AreaLandSM = " & Me.AreaLandSM WHERE ldLease = " & _
Me.num2 & ";"
Debug.Print strSql
CurrentDb.Execute strSql, dbFailOnError

By building a string, you can print it to the Immediate Window (Ctrl+G). You
can then see what is wrong with the string, and even copy it and paste it
into SQL View in a new query, to get more information about what is wrong
with it.

Note that if any of these fields are Text type (not Number type fields), you
need extra quotes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top