473,503 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error 3061, Too few parameters Expected 1

115 New Member
I tried to figure out what i did wrong, and i couldn't find the mistake could any one help me ??
i'm getting this message :Error 3061, Too few parameters Expected 1.
achat_num and fact_num are both required field.
Expand|Select|Wrap|Line Numbers
  1.   Dim db As DAO.Database
  2.   Dim dataset1, dataset2 As DAO.Recordset
  3.   Dim sql1, sql2 As String
  4.   Dim maxfactnum, maxachatnum, Article As Long
  5.  
  6.   Set db = CurrentDb
  7.   Set dataset1 = db.OpenRecordset("select nz(max(achat_num),0) as maxAchatNum from achat", dbOpenDynaset)
  8.   Set dataset2 = db.OpenRecordset("select nz(max(fact_num),0) as maxFactNum from Facture", dbOpenDynaset)
  9.  
  10.   maxfactnum = CLng(dataset2![maxfactnum])  'the maximum fact_num in the Facture table
  11.   MsgBox (maxfactnum)
  12.   maxachatnum = CLng(dataset1![maxachatnum]) ' the maximum achat_num in the achat table
  13.   newAchatNum = maxachatnum + 1                ' the new achat_num
  14.   newFactNum = maxfactnum + 1
  15.   MsgBox (newFactNum)
  16.     sql1 = "insert into Facture values(" _
  17.             & CStr(newFactNum) & ",#" & CStr(Forms![testFact]![date_fact]) & "#," _
  18.             & CStr([testFact_Subform].Form![Real]) & "," _
  19.             & CStr([testFact_Subform].Form![After]) & "," _
  20.             & CStr([testFact_Subform].Form![cash]) & "," _
  21.             & CStr([testFact_Subform].Form![diff]) & ");"
  22.     MsgBox sql1
  23.     db.Execute (sql1)
  24.  
  25.     If (Not IsNull([testFact_Subform].Form![achat_num1])) Then
  26.         sql2 = "insert into achat values(" _
  27.             & CStr(newAchatNum) & "," & CStr([testFact_Subform].Form![Article1]) & "," _
  28.             & CStr([testFact_Subform].Form![size1]) & "," _
  29.             & CStr(newFactNum) & "," & CStr([testFact_Subform].Form![quantite_vendu1]) & "," _
  30.             & CStr([testFact_Subform].Form![prix_vente_unitaire1]) & "," _
  31.             & CStr([testFact_Subform].Form![Difference1]) & "," _
  32.             & CStr([testFact_Subform].Form![Type1]) & "); "
  33.         MsgBox sql2
  34.         db.Execute (sql2)  'this line is highlighted with yellow on debug
  35.     End If
  36.  
  37.  
Aug 17 '10 #1
12 1698
code green
1,726 Recognized Expert Top Contributor
The usual problem with this error is you have got a field name wrong
Aug 17 '10 #2
hannoudw
115 New Member
Yes that's what i thought but i checked them zillion time and they are all right field names!!
Aug 17 '10 #3
hannoudw
115 New Member
The weird thing is that in the prompt message the sql2 seems to be right , cause i got this right value of inserted fields!!
does any one know the problem ?
Aug 17 '10 #4
NeoPa
32,557 Recognized Expert Moderator MVP
If you want us to check your SQL I suggest you post your SQL.

Expecting us to go the extra mile to save you the effort is not likely to win you too much sympathy.
Aug 17 '10 #5
hannoudw
115 New Member
Expand|Select|Wrap|Line Numbers
  1. sql1 = "insert into achat values(" _
  2. newAchatNum,Article1,size1,newFactNum,quantite_vendu1,prix_vente_unitaire1,Difference1,Type1);"
Aug 17 '10 #6
code green
1,726 Recognized Expert Top Contributor
Are you trying to force the value of an auto-number field?
Aug 17 '10 #7
hannoudw
115 New Member
Yes had an auto number field
Aug 17 '10 #8
hannoudw
115 New Member
the primary key of the ahat table was auto number , i change it to just number but i'm still getting this error :(
Aug 17 '10 #9
hannoudw
115 New Member
I solve it
And finally ...
It seems if we forgot the quot for the string value it gives this error !
Thanks a lot guys :)
Aug 17 '10 #10
NeoPa
32,557 Recognized Expert Moderator MVP
hannoudw:
Expand|Select|Wrap|Line Numbers
  1. sql1 = "insert into achat values(" _
  2. newAchatNum,Article1,size1,newFactNum,quantite_vendu1,prix_vente_unitaire1,Difference1,Type1);"
I'm glad you managed to solve it, but this is VBA code still. Not SQL.

Never mind for now, but it's worth understanding for future questions.
Aug 17 '10 #11
Nur Alina
2 New Member
hi, i also faced this problem. what do you mean by the quot for the string value?
Jan 17 '11 #12
NeoPa
32,557 Recognized Expert Moderator MVP
I won't allow this thread to go off-topic (or deviate from the OP's requirements specifically), but this particular request can be considered relevant so a full answer to your question can be found at Quotes (') and Double-Quotes (") - Where and When to use them.
Jan 17 '11 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2051
by: Cathy | last post by:
I get this error "Too few parameters. Expected 1" when trying to run the following code. Can someone please help me. Thanks in advance Dim db As DAO.Database ' Current database Dim...
0
3297
by: Miranda Evans | last post by:
I noticed several postings about issues related to "run-time error 3061", and I observed that the solutions to these issues appear to involve correcting something within the SQL code. I'm...
2
5529
by: Steve Richfield | last post by:
There have been LOTS of postings about error 3061, but mine seems to be an even simpler case than the others. I have a simple **FUNCTIONING** query called qryEdits. Copying the SQL from the query,...
2
5928
by: fanfromfla | last post by:
I am using a database that has worked for many years for a holiday project for needy families. My organization recently upgraded its server and changed everyone to Windows XP. I just mention that...
1
2874
by: bonnie.tangyn | last post by:
Hello all I get Too few parameters expected 2 error and "The MS Jet Database engine cannot find the input table or query "myTempTablename". Make sure it exists and that its name is spelled...
4
7154
by: Richard Hollenbeck | last post by:
I thought I was very specific in this SQL request. There is a form open with a selected record (and a corresponding "lngRecipeID" on that form. The table also has a field called "lngRecipeID". ...
1
22281
by: Richard Hollenbeck | last post by:
I wonder what I'm missing? I really feel like a retard because I've been screwing with some code for a very long time. I just must be missing something very simple. In the following example,...
3
4376
by: phill86 | last post by:
Hi, I am trying to run the following query in a recordset and i get the following error message Runtime error 3061 - Too few parameters. Expected 1 i am using the following code
8
2972
Cintury
by: Cintury | last post by:
The problem is I have a function that I've created and stored in a module. I call it as an expression (e.g. total: Function(parameter)). I'm receiving the error 3061: too few parameters, expected 1....
9
2639
by: bullfrog83 | last post by:
I'm getting "Error 3061: To few parameters. Expected 2." in the CurrentDb.Execute lines in the following code: 'variables previously defined 'rstCust previously defined 'rstStdCourses...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.