473,434 Members | 1,638 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

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

1
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 6130
isladogs
456 Expert Mod 256MB
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,556 Expert Mod 16PB
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
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...
2
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 =...
2
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...
2
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...
2
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: ...
4
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;...
2
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...
2
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...
2
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...
1
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
1
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...
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: 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...
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?

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.