473,287 Members | 1,899 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,287 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 6107
isladogs
454 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,554 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...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.