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

Home Posts Topics Members FAQ

Trying to do OpenRecordset and Getting a "Too Few Parameters" Error

1 New Member
The error i get is runtime error 3061. "Too few parameters. Expected 2.

here is the code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  
  3.   Dim dbs As DAO.Database
  4.   Dim TstVal As String
  5.   Dim StrSQL As String
  6.   Dim rsSql As DAO.Recordset
  7.  
  8.   Set dbs = CurrentDb
  9.  
  10.   TstVal = GetUserName()
  11.  
  12.   StrSQL = "SELECT * FROM Table_Employees WHERE TABLE_Empolyees.Emp_PC_User_Name = " & TstVal & "; "
  13.  
  14.  Set rsSql = dbs.OpenRecordset(StrSQL, dbOpenSnapshot)
  15.  
  16.   If Not rsSql.EOF Then
  17.     With rsSql
  18.     Me.QryEmpNam = TABLE_Employees.EMP_Name
  19.     End With
  20.     Set Rs = Nothing
  21.   End If
  22.  
  23. End Sub
The underscored line is the one that Debug breaks on.

Any help would be great.
Aug 16 '22 #1
2 6155
isladogs
459 Recognized Expert Moderator Contributor
First of all you mistyped Table_Employees as TABLE_Empolyees . Fix that
Secondly, assuming User_Name is a text field, then add single quotes as the text delimiter:
Expand|Select|Wrap|Line Numbers
  1. StrSQL = "SELECT * FROM Table_Employees WHERE TABLE_Employees.Emp_PC_User_Name = '" & TstVal & "'; "
Aug 16 '22 #2
NeoPa
32,568 Recognized Expert Moderator MVP
Hi Sleach.

Welcome to Bytes.com.

I see that Colin (isladogs) has already shown you the specific problem with your SQL code.

In future though, you may benefit from a better understanding of how to explore and find bugs in your own SQL. How to Debug SQL String is where you can find out how to do this simply and easily.
Aug 17 '22 #3

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

Similar topics

4
3159
by: Dalan | last post by:
I presume that using an open recordset method is the preferred method of accomplishing what I'm trying to do. Of course, if there are other options that would work, feel free to share them. I need to provide a means of scanning one field for all records and to trigger a message upon opening the form for alerting a user that maintenance activities need to be promptly performed. The recordset does not necessarily have to be used for any...
2
6738
by: Colleyville Alan | last post by:
I ran into problems in an app in which I received a msg of "cannot lock the table, it is in use by another user". It turns out that I had opened a recordset with a command like set rstmyrecs = openrecordset("Tablename") to get a record count and I was trying to run a query to modify the table even though I had not yet closed the recorset. I fixed most of them, but I was wondering if there is a way to test if a recorset is open. I got...
2
2625
by: Hexman | last post by:
Hello All, Well I'm stumped once more. Need some help. Writing a simple select and update program using VB.Net 2005 and an Access DB. I'm using parameters in my update statement and when trying to update a record, I get a "No value given for one or more parameters." error message. I use a Select with parameters and an Update with parameters. The select works fine. I thought I've tried everything (evidently not) to get this working. ...
2
4802
by: technocraze | last post by:
Hi guys, I have encountered this error when updating the values to the MS Acess table. Error : Update on linked table failed. ODBC sql server error Timeout expired. MS Acess is my front end and sql server is my backend server. This error occured whenever i step through and when it reaches rs.update it jux hangs down there and thereafter it shwn the aforementioned error. I am using the RecordSet properties to add the values. Can I use...
2
2048
by: darkhat01 | last post by:
I am running a cross tab on a Union query and I am getting and error. The Microsoft Jet database engine does not recognize '!!' as a valid field name or expression. Here is the SQl code: TRANSFORM Count(.IDCount) AS Expr1 SELECT . AS Expr2, Count(.IDCount) AS FROM WHERE (((.Database)<>"ASOF")) GROUP BY .
4
2095
by: preeti13 | last post by:
Hi friends i have a probelm i am try to pass the value to the employeeid parameter but getting th error please help me how i can do this i am getting the error here is my code using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI;
2
3708
by: Brad Nerbovig | last post by:
I am getting this error when connecting to an Excel file from Access 2010. The weird thing is, if I click on okay when the routing fails, and then run it again it works just fine. In fact, if I run it again anytime after I have gotten this error it works just fine. The only time the error crops up is the first time I run the routine after opening up the database. There's a lot of code in this routine which I'll post, but the error occurs at...
2
1194
by: firebirdxvi | last post by:
I am using Access 2010 and I am getting this error: "Current Recordset does not support updating. There may be a limitation of the provider, or of the selected locktype." Dim SQLstr as String Dim R as ADODB.Recordset Set R = New ADODB.Recordset SQLstr = "SELECT * FROM TABLE1;" R.OPEN SQLstr, CurrentProject.Connection, _
2
3379
by: time2hike | last post by:
I have a command button that pulls an Adobe RecordSet and Exports the data to Excel. One of my users reports getting Error 6 Overflow when running the export for a particular criteria. I thought that it was because the recordset contained too many records, but when I look at the records for the criteria there is currently 44,461 records and Microsoft allows me to export these manually. I stepped through the code and found that it fails on...
1
1113
by: srhollis | last post by:
I am trying to design a simple database that has one form (frmSessions) where a person will enter sessions for an upcoming conference we are planning. The purpose of the form is to prevent us from double-booking a room. The form has 7 fields that should get saved to a table called tblSessions. The user must enter the Session Title, Choose a date from a list box, choose a room from a list box, and then Choose a start time from a list box. I...
0
8421
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
8325
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8844
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8621
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7354
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...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
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
1734
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.