473,657 Members | 2,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Run-Time Error 3061

124 New Member
I'm getting "Error 3061: To few parameters. Expected 2." in the CurrentDb.Execu te lines in the following code:

Expand|Select|Wrap|Line Numbers
  1. 'variables previously defined
  2. 'rstCust previously defined
  3. 'rstStdCourses previously defined
  4.  
  5. Do While Not rstStdCourses.EOF
  6.   varTakenCourseId = rstCust!TakenCourseId
  7.   blnWaived = rstCust!Waived
  8.   lngStdDegReqCourseId = rstStdCourses!StdDegReqCourseId
  9.   'If some criteria is met Then
  10.     CurrentDb.Execute "UPDATE StdDegReqCourse SET TakenCourseId = varTakenCourseId, Waived = blnWaived, Customized = -1 WHERE StdDegReqCourseId = " & lngStdDegReqCourseId
  11.     Exit Do
  12.   Else
  13.   End If
  14.   rstStdCourses.MoveNext
  15. Loop
  16.  
The values for the variables are as follows:

varTakenCourseI d = Null (variable datatype as I need it to accept nulls)
blnWaived = True
lngStdDegReqCou rseId = 9122

I am unable to determine where the problem lies.
Jun 2 '10 #1
9 2646
Dan2kx
365 Contributor
Could it be an error in your SQL?

It appears to me that you havent put your variables in correctly...

Specifically blnWaived and varTakenCourseI D
You need to wrap them in " & VARIABLE & " depending on there data type....
eg '" & STRING & "' OR " & LONG/INTEGER & " OR #" & DATE & "#
(you dont need the ' for Null or True)

eg....
Expand|Select|Wrap|Line Numbers
  1. "UPDATE StdDegReqCourse SET TakenCourseId = " & varTakenCourseId & ", Waived = " & blnWaived & ", Customized = -1 WHERE StdDegReqCourseId = " & lngStdDegReqCourseId
You could also try to debug.print this SQL to see what you the string actually constructs and try running the SQL in query builder.

Hope it works, I not an expert tho (just a bit bored (LOL))

Dan
Jun 2 '10 #2
bullfrog83
124 New Member
@Dan2kx
Duh! I knew it was something simple. Thanks! However, you said that if a value is Null I don't need the '. However, if varTakenCourseI d is Null, using the debug.print that you recommended, this is what is being constructed:

Expand|Select|Wrap|Line Numbers
  1. UPDATE StdDegReqCourse SET TakenCourseId = , Waived = True, Customized = -1 WHERE StdDegReqCourseId = 9622
  2.  
It appears to be rendering the Null as a blank. In order to not do that I had to add the extra apostrophe as such: '" & varTakenCourseI d & "' I didn't need it for the blnWaived variable, though. Any thoughts?
Jun 3 '10 #3
Dan2kx
365 Contributor
If your data type for varTakenCourseI D is set to variant then you are correct, it will not print the NULL value in the SQL (my mistake, wasn't thinking), im my test it does not print it with the single quotes either....

what you actually need to do in this situation would be this

Expand|Select|Wrap|Line Numbers
  1. " & nz(varTakenCourseID, "Is Null") & "
You can search help for an accurate description of the nz() function but basically it turns a null value into whatever you want... if it is null of course.

This would then supply the "null" in the correct format for the SQL if the value is null (which is: "Is Null" (without quotes)), i assume that this variable is normally a number so this would also satisfy the number format also.

Hope this makes sense

Dan
Jun 3 '10 #4
patjones
931 Recognized Expert Contributor
I think you are almost there, but "Is Null" won't work in the Nz function call. I would say to write it as Nz(varTakenCour seID, Null), however it may or may not work depending on the properties of the column TakenCourseId.

What is the data type of TakenCourseId?

Pat
Jun 3 '10 #5
bullfrog83
124 New Member
@Dan2kx
That works! I had to edit it though to be Nz(varTakenCour seId,Null). Thank you very much! You have been very helpful!
Jun 3 '10 #6
Dan2kx
365 Contributor
@zepphead80
Like you say, it depends on the Datatype, i assumed it was Variant.

Glad its solved for ya BullFrog

Dan
Jun 3 '10 #7
patjones
931 Recognized Expert Contributor
@bullfrog83
I should clarify what I just wrote. As Dan2kx wrote the Nz function call, it will work in the sense that it will insert the string "Is Null" in the column. However if you want the entry to be truly null, you need to specify the Null keyword in the Nz function call.

Pat
Jun 3 '10 #8
bullfrog83
124 New Member
@zepphead80
The datatype for TakenCourseId is Number (Long Integer) at the table level but I made the variable in my proc a variant so it can handle nulls since Long can't.
Jun 3 '10 #9
bullfrog83
124 New Member
@zepphead80
Thanks! I've used the Nz function before but forgot about it so when Dan suggested it, I knew I had to have Null instead of Is Null.
Jun 3 '10 #10

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

Similar topics

1
5170
by: James | last post by:
Hi, I would like to run a custom script on a linux box via a button on a php page (php webpage hosted on the same linux box). Is this possible? If so , can you give me a pointer in the right direction? thanks James
3
4923
by: leroybt.rm | last post by:
Can someone tell me how to run a script from a interactive shell I type the following: >>>python filename >>>python filename.py >>>run filename >>>run filename.py >>>/run filename >>>/run filename.py
4
3212
by: Ed | last post by:
Hello, I took a course in asp about 2 years ago and I was practicing with IIS 5.0. Then I put it down for a while. Now trying to get back to it. I can't run asp files from subdirectories of my root directory, but I can run asp files from the root directory of my website and I can run htm files from the subdirectories. If I run localhost/mytest.asp
2
2535
by: Jenna Olson | last post by:
Hi all- I've never seen this particular issue addressed, but was wondering if there's anything to support one way or another. Say I have a class: class ManipulateData { public: ManipulateData(const char* Path-To-Some-Text-File) { ... }
2
3680
by: Napo | last post by:
Hi: i build a .net application named A.exe. I need run this application twice using c# code in another application. i try to use process.start(A.exe) twcie, but it failed. Because the second start will use the existed process. So only one application run. I can use mouse to run this application twice, and there are two A.exe processes in processed pool. So how can i do the same work using code but not manu-click?
6
20066
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are quite a few words in this post but the questions are actually quite similar and should be fairly quick to answer ... (1) What is Happening with the Threads
13
5072
by: Bob Day | last post by:
Using vs2003, vb.net I start a thread, giving it a name before start. Code snippet: 'give each thread a unique name (for later identification) Trunk_Thread.Name = "Trunk_0_Thread" ' allow only 1 thread per line Trunk_Thread.ApartmentState = ApartmentState.STA
9
4672
by: Brett Wesoloski | last post by:
I am new to VS2005. I changed my program.cs file to be a different form I am working on. But when I go to run the application it still brings up the form that was originally declared as new. When I put in a break point the program does not stop. It is in debug mode. If I change the program.cs file back to the form that was originally being used. The program does go into debug mode. But if I change code in that file it isn't using...
8
3006
by: David Thielen | last post by:
Hi; In our setup program how do I determine if I need to run "aspnet_regiis –i" and if so, is there an API I can calll rather than finding that program on the user's disk and calling it? -- thanks - dave david_at_windward_dot_net http://www.windwardreports.com
3
11290
by: traceable1 | last post by:
Is there a way I can set up a SQL script to run when the instance starts up? SQL Server 2005 SP2 thanks!
0
8392
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7324
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1611
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.