473,473 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

runtime error 3061 too few parameters expected 1

3 New Member
I've tried Literal type characters around the variable Can not get it to work:

Expand|Select|Wrap|Line Numbers
  1. Sub test()
  2. Dim CustNum As Integer
  3. Set DB = CurrentDb
  4. Set CustomerRS = DB.OpenRecordset("tbl-customer")
  5.  
  6. CustNum = 20671
  7.  
  8. Set CustomerRS = DB.OpenRecordset("SELECT [tbl-Customer].*, [tbl-Customer].[Customer ID]FROM [tbl-Customer]WHERE [Customer ID]=CustNum")
  9.  
  10. CustomerName = CustomerRS![Name]
  11.  
  12. Debug.Print CustomerRS![Name]
  13.  
  14. CustomerRS.Close
  15.  
  16. DB.Close
  17.  
  18. Set DB = Nothing
  19. End Sub
Jun 9 '15 #1

✓ answered by Rabbit

What you're searching for right now is the string custnum. Not the value you're storing in custnum. You need to append the value of the variable, not the string.

Expand|Select|Wrap|Line Numbers
  1. 1.Set CustomerRS = DB.OpenRecordset("SELECT [tbl-Customer].*, [tbl-Customer].[Customer ID] FROM [tbl-Customer] WHERE [Customer ID]=" & CustNum)

4 1285
jforbes
1,107 Recognized Expert Top Contributor
My guess is there needs to be a couple spaces, one in front of FROM and another in front of WHERE:
Expand|Select|Wrap|Line Numbers
  1. Set CustomerRS = DB.OpenRecordset("SELECT [tbl-Customer].*, [tbl-Customer].[Customer ID]_FROM [tbl-Customer]_WHERE [Customer ID]=CustNum")
Jun 9 '15 #2
ASpasaro
3 New Member
I tested the statement by substituting a number for the variable CustNum and it works perfectly.

I am fairly certain that my problem lies after the = in the where statement : WHERE [Customer ID]=CustNum
Jun 9 '15 #3
Rabbit
12,516 Recognized Expert Moderator MVP
What you're searching for right now is the string custnum. Not the value you're storing in custnum. You need to append the value of the variable, not the string.

Expand|Select|Wrap|Line Numbers
  1. 1.Set CustomerRS = DB.OpenRecordset("SELECT [tbl-Customer].*, [tbl-Customer].[Customer ID] FROM [tbl-Customer] WHERE [Customer ID]=" & CustNum)
Jun 9 '15 #4
ASpasaro
3 New Member
Rabbit

I cannot thank you enough It worked perfectly

Thanks again
ASpasaro
Jun 9 '15 #5

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

Similar topics

3
by: colm | last post by:
i get the above runtime error on the following line of code when i try to update a reord in my form when it gets to the line Set rs = DBEngine(0)(0).OpenRecordset(strSql) the entire code...
2
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...
4
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". ...
4
by: JH001A | last post by:
ACCESS 2003 VBA in the code below set.rs3, gets the error when I try using a parm for input to the where clause. If I use a number like the one comented out it works. Thanks for your help. ...
10
RMWChaos
by: RMWChaos | last post by:
WinVista/IE7 I am getting some weird errors only in IE7, but not in FF2.0.0.8 or NN9. It even happens on this website when I click "Sign In". The error is: "A Runtime Error has occurred."...
1
by: istya | last post by:
I am having a dumb day to day. Can anyone have a schufty at my code and see why I am getting the runtime error 3061? I'm working on 2000 if that helps at all. Dim dbs As DAO.Database Dim...
3
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
4
by: shalskedar | last post by:
In my DB(Ms Access 2003)I want to delete a record from 1 table which is linked to another table. For ex- There are 2 tables "MasterType" which is the Master table & another table as "Sash DO"...
8
by: Viv Jones | last post by:
Hi I am trying to update a recordset, however, I cannot get the code to run as i get Runtime Error: 3061. Too Few Parameters. Expected 1. Line 6 is highlighted when you debug. Any assistance...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...
0
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
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.