Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime error 3061: Too few parameters. Expected 2. 1

Status
Not open for further replies.

CapnOats

Programmer
Apr 15, 2004
35
GB
Can anyone here shed some light on this problem whenever the code below is run the following error appears


Runtime error 3061

Too few parameters. Expected 2.

This is the code that causes it, the long line of SQL is where it stops.

Code:
Dim Db As DAO.Database
Dim strSQL As String

Set Db = CurrentDb

Db.Execute "UPDATE Work SET [Hours Worked] = '" & hoursText & "' WHERE Job.[FM Reference] = '" & fmRefText & "' AND Job.[SE Reference] = '" & seRefText & "' AND [Designer] = '" & techCombo & " '"

hopefully someone can lend a hand here as according to the help file any other parameters are purely optional - and if I need to use one what would it be - I dont fully understand what they are going on about -

maybe its "a case of the mondays" i dunno



Regards,
Mike
 
Hi Mike.

If you don't need to store the SQL statement or use a recordset, you can use the DoCmd.RunSQL command:
Code:
Dim strSQL As String
strSQL= "UPDATE Work SET [Hours Worked] = '" & hoursText & _
"' WHERE Job.[FM Reference] = '" & fmRefText & "' AND Job.[SE Reference] = '" & _
seRefText & "' AND [Designer] = '" & techCombo & " '" 
' DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
' DoCmd.SetWarnings True

P.S: Make sure to backup your db before doing mass updates - cause anything that can go wrong, will go wrong (Murphy's Law) ;-)

The Execute method belongs to ADO, if I'm not mistaken, so would need to establish a connection first...

Cheers,
Andy

[blue]The last voice we will hear before the world explodes will be that of an expert saying:
"This is technically impossible!" - Sir Peter Ustinov[/blue]
andreas.galambos@bowneglobal.de
HP:
 
that works brilliantly but now

Code:
DoCmd.RunSQL "INSERT INTO Work VALUES ('" & seRefText & "', '" & fmRefText & "', '" & techCombo & "', '" & hoursText & "') WHERE Job.[FM Reference] = '" & fmRefText & "' AND Job.[SE Reference] = '" & seRefText & "';"

doesnt work - missing semicolon at end of SQL statement

hmm, well I can see one

Regards,
Mike
 
Hmm - me too.
Check if your strSQL string is in one line - or all lines connected via the underscore at the end of each line.
I assume your SQL string is interrupted.


Hope this helps,
Andy
 
its ok, i worked out where the error is occuring - ill post back here for everyone once i work out a way around it

Regards,
Mike
 
Anyway, aren't Work and Job two different tables not joined ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top