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. -
Dim db As DAO.Database
-
Dim dataset1, dataset2 As DAO.Recordset
-
Dim sql1, sql2 As String
-
Dim maxfactnum, maxachatnum, Article As Long
-
-
Set db = CurrentDb
-
Set dataset1 = db.OpenRecordset("select nz(max(achat_num),0) as maxAchatNum from achat", dbOpenDynaset)
-
Set dataset2 = db.OpenRecordset("select nz(max(fact_num),0) as maxFactNum from Facture", dbOpenDynaset)
-
-
maxfactnum = CLng(dataset2![maxfactnum]) 'the maximum fact_num in the Facture table
-
MsgBox (maxfactnum)
-
maxachatnum = CLng(dataset1![maxachatnum]) ' the maximum achat_num in the achat table
-
newAchatNum = maxachatnum + 1 ' the new achat_num
-
newFactNum = maxfactnum + 1
-
MsgBox (newFactNum)
-
sql1 = "insert into Facture values(" _
-
& CStr(newFactNum) & ",#" & CStr(Forms![testFact]![date_fact]) & "#," _
-
& CStr([testFact_Subform].Form![Real]) & "," _
-
& CStr([testFact_Subform].Form![After]) & "," _
-
& CStr([testFact_Subform].Form![cash]) & "," _
-
& CStr([testFact_Subform].Form![diff]) & ");"
-
MsgBox sql1
-
db.Execute (sql1)
-
-
If (Not IsNull([testFact_Subform].Form![achat_num1])) Then
-
sql2 = "insert into achat values(" _
-
& CStr(newAchatNum) & "," & CStr([testFact_Subform].Form![Article1]) & "," _
-
& CStr([testFact_Subform].Form![size1]) & "," _
-
& CStr(newFactNum) & "," & CStr([testFact_Subform].Form![quantite_vendu1]) & "," _
-
& CStr([testFact_Subform].Form![prix_vente_unitaire1]) & "," _
-
& CStr([testFact_Subform].Form![Difference1]) & "," _
-
& CStr([testFact_Subform].Form![Type1]) & "); "
-
MsgBox sql2
-
db.Execute (sql2) 'this line is highlighted with yellow on debug
-
End If
-
-
12 1698 code green 1,726
Recognized Expert Top Contributor
The usual problem with this error is you have got a field name wrong
Yes that's what i thought but i checked them zillion time and they are all right field names!!
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 ?
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.
- sql1 = "insert into achat values(" _
-
newAchatNum,Article1,size1,newFactNum,quantite_vendu1,prix_vente_unitaire1,Difference1,Type1);"
code green 1,726
Recognized Expert Top Contributor
Are you trying to force the value of an auto-number field?
Yes had an auto number field
the primary key of the ahat table was auto number , i change it to just number but i'm still getting this error :(
I solve it
And finally ...
It seems if we forgot the quot for the string value it gives this error !
Thanks a lot guys :)
NeoPa 32,557
Recognized Expert Moderator MVP hannoudw: - sql1 = "insert into achat values(" _
-
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.
hi, i also faced this problem. what do you mean by the quot for the string value?
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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,...
|
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...
|
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...
| |
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". ...
|
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,...
|
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
|
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....
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| | |