|
-
Sep 29th, 2008, 12:11 PM
#1
Thread Starter
New Member
[RESOLVED] run time error '3061'
I Create an access 97 db with a table named students and connect it with a vb6 form using data control
when i search for the recored between two numbers( the caqlculation of 3 subjects exam) i get a run time error '3061' when execute the code below
can any one you help me in this case
Private Sub Command1_Click()
Dim x As Double
Dim y As Double
x = InputBox(" Enter First Number")
y = InputBox(" Enter SecondNumber")
Data1.RecordSource = "SELECT * From students WHERE sub1+sub2+sub3 > x And sub1 + sub2 + sub3 < y "
Data1.Refresh
End Sub
-
Sep 29th, 2008, 12:24 PM
#2
Re: run time error '3061'

I moved your thread to the proper forum.
-
Sep 29th, 2008, 12:55 PM
#3
Re: run time error '3061'
I can only guess as to what message is given for error 3061, but I assume it is complaining about x and y (as they only exist in your VB code, not in the database where the SQL statement is running).
This can be solved by putting the values of x and y into the SQL statement instead, as shown in the article How can I put the value of a variable/control into my SQL statement? from the "SQL" section of our Database Development FAQs/Tutorials (at the top of the Database Development forum)
-
Sep 29th, 2008, 01:08 PM
#4
Re: run time error '3061'
3061 = "Application-defined or object-defined error"
-
Sep 29th, 2008, 01:16 PM
#5
Re: run time error '3061'
This needs to be addressed. I'm not precisely sure what you are trying to do here so I going to proceed under the assumption that the "subs" are fields in your database and that each need to contain a value greater than x and less then y to meet your criteria. If this is true then
Code:
'you would need to change this
WHERE sub1+sub2+sub3 > x And sub1 + sub2 + sub3 < y
'to this
WHERE sub1 > x
AND sub2 > x
AND sub3 > x
AND sub1 < y
And sub1 < y
AND sub3 < y
-
Sep 29th, 2008, 02:26 PM
#6
Re: run time error '3061'
 Originally Posted by MartinLiss
3061 = "Application-defined or object-defined error"
Unfortunately that message is just VB's way of saying "I don't know".
Adding the relevant references/components may well be enough to make it show the proper message, but in some cases (particularly when databases are involved) the error message is actually generated at runtime.
A quick web search on "error 3061" shows many cases of the message being "Too few parameters. Expected n", which is usually caused by the issue I explained - so the link I provided will hopefully solve the error.
-
Sep 30th, 2008, 01:44 AM
#7
Re: run time error '3061'
Same as others, I am not sure what you want to do, perhaps it should be like this:
Data1.RecordSource = "SELECT * From students WHERE (sub1+sub2+sub3) > " & x & " And (sub1 + sub2 + sub3) < " & y
-
Sep 30th, 2008, 02:10 AM
#8
Re: run time error '3061'
Also if you are going to be adding fields then they should be of the proper data types.
sub1+sub2+sub3
Should all be numeric data types.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 30th, 2008, 05:42 AM
#9
Thread Starter
New Member
Re: run time error '3061'
 Originally Posted by anhn
Same as others, I am not sure what you want to do, perhaps it should be like this:
Data1.RecordSource = "SELECT * From students WHERE (sub1+sub2+sub3) > " & x & " And (sub1 + sub2 + sub3) < " & y
thanks to all
the code above fix the error, and when i type it as show the error '3061' disappeared.
thanks again
-
Sep 30th, 2008, 06:01 AM
#10
Re: run time error '3061'
Now that we've helped you, you can help us by pulling down the Thread Tools menu and selecting the Mark Thread Resolved item which will let everyone know that you have your answer. Also if someone has been particularly helpful you have the ability to affect a their forum "reputation" by rating their post. Only those ratings that you give after you have 20 posts will actually count, but in all cases the person you rate will see it and know that you appreciate their help.
-
Oct 2nd, 2008, 05:15 AM
#11
Thread Starter
New Member
Re: run time error '3061'
Si the Greek, Martin Liss , Hack , Anhn and Robdog888
thank you for your help
i do appreciate that
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|