By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,397 Members | 1,083 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,397 IT Pros & Developers. It's quick & easy.

Error 3061 has occurred at run time. Few parameters. Expected 1

P: 10
Good morning I'm calling again about a problem with SELECT, please.

Expand|Select|Wrap|Line Numbers
  1. Set rs1 = DB.OpenRecordset("Select   [RADICADO], " _
  2.                   & "[Cedula Cliente] FROM BaseDatosMatriz " _
  3.                   & "where [CEDULA CLIENTE] = [Form]![CEDULA]")
HAVE LOOKED FOR IT AND ALL THE FIELDS ARE WELL SITUATED
BUT I DON'T KNOW. PLEASE IF YOU GIVE ME A HELP. THANK YOU
VERY MUCH.
Expand|Select|Wrap|Line Numbers
  1.   [RADICADO]           SHORT TEXT   FIELD SIZE  23
  2.   [CEDULA CLIENTE ]    SHORT TEXT   FIELD SIZE  12
  3.   CEDULA               SHORT TEXT   FIELD SIZE  12

Expand|Select|Wrap|Line Numbers
  1. Dim DB As Database
  2. Dim rs As Recordset
  3. Dim rs1 As Recordset
  4. Set DB = CurrentDb
  5. Set rs = DB.OpenRecordset("BaseDatosMatriz")
  6.  
  7. Set rs1 = DB.OpenRecordset("Select * ,[RADICADO], " _
  8. & "[Cedula Cliente] FROM BaseDatosMatriz " _
  9. & "where [CEDULA CLIENTE] = CEDULA")
Oct 20 '20 #1
Share this Question
Share on Google+
4 Replies

isladogs
Expert
P: 54
... "where [CEDULA CLIENTE] = '" & CEDULA & "'")
Oct 21 '20 #2

twinnyfo
Expert Mod 2.5K+
P: 3,548
Eddy,

A good practice to get into is to always declare a string variable for your SQL statement. This 1) allows you to evaluate the string for errors and 2) sometimes access doesn't like to include static/form references when you try to set a recordset that way. I would recommend something like this (including IslaDogs' correction):

Expand|Select|Wrap|Line Numbers
  1. Dim DB As Database
  2. Dim rs As Recordset
  3. Dim rs1 As Recordset
  4. dim strSQL As String
  5.  
  6. strSQL = _
  7.     "SELECT " & _
  8.         "[RADICADO], " & _
  9.         "[Cedula Cliente] " & _
  10.     "FROM " & _
  11.         "BaseDatosMatriz " & _
  12.     "WHERE " & _
  13.         "[CEDULA CLIENTE] = '" & [Form]![CEDULA] & ";"
  14.  
  15. Set DB = CurrentDb
  16. Set rs = DB.OpenRecordset("BaseDatosMatriz")
  17. Set rs1 = DB.OpenRecordset(strSQL)
Thus, at any point in your code, you could insert: Debug.Print strSQL and that value will be sent to your immediate window. You can then evaluate or copy and paste into your query editor to see how it works.

Hope that hepps!
Oct 21 '20 #3

P: 10
sla thank you very much, for that help, God bless you.
Also to Twinnyfo for advice on structuring the codes in an easy way to get the bugs.

thank you very much.
Eddy
Oct 21 '20 #4

isladogs
Expert
P: 54
On behalf of us both, you're welcome
Oct 21 '20 #5

Post your reply

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