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

error 3061 como solvento este error

P: 8
al ejecutar

Expand|Select|Wrap|Line Numbers
  1. db.Execute "INSERT INTO BaseDatosMatriz" _
  2.     & "([CEDULA CLIENTE],[ID_JURIS],[ID_ESP],[TIPO DE PROCESO],[RADICADO]," _
  3.     & "[DEMANDATES],[DEMANDADOS],[CAUSANTE],[CURADOR],[FECHA_DE_REGISTRO]," _
  4.     & "[NUMERO CARPETA],[CAJA],[NOTAS],[APDE_DEMANDANTES],[APDE_DEMANDADOS],[FECHA_FIN])" _
  5.     & "values( Form![CEDULA CLIENTE],Form![ID_JURIS],Form![ID_ESP],Form![TIPO DE PROCESO],Form![RADICADO]," _
  6.     & "Form![DEMANDATES],Form![DEMANDADOS],Form![CAUSANTE],Form![CURADOR],Form![FECHA_DE_REGISTRO]," _
  7.     & "Form![NUMERO CARPETA],Form![CAJA],Form![NOTAS],Form![APDE_DEMANDANTES],Form[APDE_DEMANDADOS],Form![FECHA_FIN]);"
  8.  
  9. db.Close
Al llenar formulario me indica error 3061 en tiempo de ejecucion, se esperaba 16 parametros aun colocandole todos los parametros en cada campo. alguien me puede ayudar con eso

==============================================
English Translation:
when executing

{CODE}

When filling out the form it indicates error 3061 at runtime, 16 parameters were expected even placing all the parameters in each field. can someone help me with that
4 Weeks Ago #1

✓ answered by ADezii

@twinnyfo:
One day I keep you on your toes, the next day you keep me on my toes! (LOL)

P.S. - We also have to take into consideration that there may be 1 or more DATE/TIME Fields that will also have to be Delimited. As you stated, we need an English Version along with all Data Types for Fields involved in the SQL Statement. Take care and stay safe.

Share this Question
Share on Google+
15 Replies

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

First, Welcome to Bytes!

Second, we request posters to use English on our forum, so please do so, if possible. We always try to work through language challenges with you.

Third, fundamentally, there may not be be anything wrong with your Code, but MS Access has a tendency to not like using references to form controls directly from within its executable functions. What I mean by that is that it is often better (and in practice I always do this) to generate a finished string variable and then send that string to the function. You also need to be careful to use the proper punctuation and syntax here. This also allows you to evaluate your string before you use it and examine that string within the Query Builder of Access.

Fourth, it is unclear what "Form!" refers to. as it stands, Access has no idea what you are telling it to get. If this code is resident on a form, and the items in square brackets are controls on that Form, then the proper sytax would be simply "Me.". I am assuming this is the case, so I have modified that in your code.

As a final recommendation, as I do with all examples of this sort, I highly recommend that you name your controls something other than merely the name of the field to which they apply. So, a text box that holds the data for [CEDULA CLIENTE] has a name of txtCedulaCliente. This allows Access to differentiate between the text box and the underlying field--which is sometimes helpful, not to mention the ambiguities that are raised when you don't employ this practice.

Also,it looks like you may have missed a few required spaces. See below:

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Option Compare Database
  3.  
  4. Private Sub YourSubName()
  5.     Dim strSQL As String
  6.     Dim db As DAO.Database
  7.  
  8.     strSQL = _
  9.         "INSERT INTO BaseDatosMatriz (" & _
  10.             "[CEDULA CLIENTE], " & _
  11.             "[ID_JURIS], " & _
  12.             "[ID_ESP], " & _
  13.             "[TIPO DE PROCESO], " & _
  14.             "[RADICADO], " & _
  15.             "[DEMANDATES], " & _
  16.             "[DEMANDADOS], " & _
  17.             "[CAUSANTE], " & _
  18.             "[CURADOR], " & _
  19.             "[FECHA_DE_REGISTRO], " _
  20.             "[NUMERO CARPETA], " & _
  21.             "[CAJA], " & _
  22.             "[NOTAS], " & _
  23.             "[APDE_DEMANDANTES], " & _
  24.             "[APDE_DEMANDADOS], " & _
  25.             "[FECHA_FIN]) "
  26.     strSQL = strSQL & _
  27.         "VALUES (" & _
  28.             Me.[CEDULA CLIENTE] & ", " & _
  29.             Me.[ID_JURIS] & ", " & _
  30.             Me.[ID_ESP] & ", " & _
  31.             Me.[TIPO DE PROCESO] & ", " & _
  32.             Me.[RADICADO] & ", " & _
  33.             Me.[DEMANDATES] & ", " & _
  34.             Me.[DEMANDADOS] & ", " & _
  35.             Me.[CAUSANTE] & ", " & _
  36.             Me.[CURADOR] & ", " & _
  37.             Me.[FECHA_DE_REGISTRO] & ", " & _
  38.             Me.[NUMERO CARPETA] & ", " & _
  39.             Me.[CAJA] & ", " & _
  40.             Me.[NOTAS] & ", " & _
  41.             Me.[APDE_DEMANDANTES] & ", " & _
  42.             Me.[APDE_DEMANDADOS] & ", " & _
  43.             Me.[FECHA_FIN] & ");"
  44.  
  45.     Set db = CurrentDB()
  46.     db.Execute
  47.     db.Close
  48.  
  49. End Sub
Hope this hepps!
3 Weeks Ago #2

ADezii
Expert 5K+
P: 8,741
My guess would be that you are not Delimiting Text Fields:
Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2. Dim strFName As String
  3. Dim strLName As String
  4. Dim lngZip As Long
  5. Dim db As DAO.Database
  6.  
  7. strFName = "A"
  8. strLName = "Dezii"
  9. lngZip = 9999
  10.  
  11. strSQL = "INSERT INTO Employees([First Name],[Last Name],[Zip]) VALUES('" & strFName & "','" & _
  12.                                  strLName & "'," & lngZip & ");"
  13. Set db = CurrentDb
  14.  
  15. db.Execute strSQL, dbFailOnError
  16.  
  17. db.Close
  18. Set db = Nothing
3 Weeks Ago #3

twinnyfo
Expert Mod 2.5K+
P: 3,529
ADezii,

Thanks for the reminder that the syntax for numeric and string values will be different!

Always keeping me on my toes!
3 Weeks Ago #4

ADezii
Expert 5K+
P: 8,741
@twinnyfo:
One day I keep you on your toes, the next day you keep me on my toes! (LOL)

P.S. - We also have to take into consideration that there may be 1 or more DATE/TIME Fields that will also have to be Delimited. As you stated, we need an English Version along with all Data Types for Fields involved in the SQL Statement. Take care and stay safe.
3 Weeks Ago #5

P: 8
buenas tardes,gracias por darme la oportunidad de solicitar el problema. ya coloque la forma que tu lo requieres. pero cuando al ejecutar nos indica que tiene error en INSERT INTO, en la instruccion "db.Execute strSQL", por favor si puedes dar una ayuda. Anexo las notas de auxiliar.

Dim strSQL As String
Dim db As DAO.Database
strSQL = _
"INSERT INTO BaseDatosMatriz (" & _
"[CEDULA CLIENTE]," & _
"[ID_JURIS]," & _
"[ID_ESP]," & _
"[TIPO DE PROCESO]," & _
"[RADICADO]," & _
"[DEMANDANTES]," & _
"[DEMANDADOS]," & _
"[CAUSANTE]," & _
"[CURADOR]," & _
"[FECHA_DE_REGISTRO]," & _
"[NUMERO CARPETA]," & _
"[CAJA]," & _
"[NOTAS]," & _
"[APDE_DEMANDANTES]," & _
"[APDE_DEMANDADOS]," & _
"[FECHA_FIN])"

strSQL = strSQL & _
"values( " & _
Me.CEDULA_CLIENTE & ", " & _
Me.ID_JURIS & ", " & _
Me.ID_ESP & ", " & _
Me.TIPO_DE_PROCESO & ", " & _
Me.RADICADO & ", " & _
Me.DEMANDANTES & ", " & _
Me.DEMANDADOS & ", " & _
Me.CAUSANTE & ", " & _
Me.CURADOR & ", " & _
Me.FECHA_DE_REGISTRO & ", " & _
Me.NUMERO_CARPETA & ", " & _
Me.CAJA & ", " & _
Me.NOTAS & ", " & _
Me.APDE_DEMANDANTES & ", " & _
Me.APDE_DEMANDADOS & ", " & _
Me.FECHA_FIN & ");"
Set db = CurrentDb()

db.Execute strSQL
db.Close

nota: todos los campos son de texto y dos Fechas dd/mm/aaaa

Muchas Gracias.
EDDY
3 Weeks Ago #6

ADezii
Expert 5K+
P: 8,741
Necesitamos la traducción al inglés para poder ayudarlo, así como todos los tipos de datos en la tabla BaseDatosMatriz.
We need the English Translation in order to assist you, as well as all the Data Types in the BaseDatosMatriz Table.
3 Weeks Ago #7

P: 8
good afternoon, thanks for giving me the opportunity to request the problem. I already put the form that you require. but when when executing it tells us that it has an error in INSERT INTO
Abrir en Google Traductor
Com

Dim strSQL As String
Dim db As DAO.Database
strSQL = _
"INSERT INTO BaseDatosMatriz (" & _
"[CEDULA CLIENTE]," & _
"[ID_JURIS]," & _
"[ID_ESP]," & _
"[TIPO DE PROCESO], "& _
" [RADICADO], "& _
" [DEMANDANTES], "& _
" [DEMANDADOS], "


"[FECHA_DE_REGISTRO]," & _
"[NUMERO CARPETA]," & _
"[CAJA]," & _
"[NOTAS]," & _
"[APDE_DEMANDANTES]," & _
"[APDE_DEMANDADOS]," & _
" [FECHA_FIN]) "

strSQL = strSQL & _
" valores ("& _
Me.CEDULA_CLIENTE &", "& _
Me.ID_JURIS &", "& _
Me.ID_ESP &", "& _
Me.TIPO_DE_PROCESO &", " & _
Yo.RADICADO & "," & _
Yo.DEMANDANTES & ", "& _
Me.DEMANDADOS &", "& _
Me.CAUSANTE &", "& _
Me.CURADOR &", "& _
Yo.FECHA_DE_REGISTRO & "," & _
Yo.NUMERO_CARPETA & "," & _
Yo.CAJA & "," & _
Yo.NOTAS & "," & _
Yo.APDE_DEMANDANTES & "," & _
Yo.APDE_DEMANDADOS & " , "& _
Me.FECHA_FIN &"); "
Set db = CurrentDb ()

db.Execute strSQL
db.Close

note: all fields are text and two Dates mm / dd / yyyy

EDDY
3 Weeks Ago #8

ADezii
Expert 5K+
P: 8,741
What two Fields are the Date Fields?
3 Weeks Ago #9

P: 8
good afternoon, thanks for giving me the opportunity to request the problem. I already put the form that you require. but when you can execute it tells us that it has an error in INSERT INTO, in the instruction "db.Execute strSQL", please give a help. Annex the auxiliary notes.

Dim strSQL As String
Dim db As DAO.Database
strSQL = _
"INSERT INTO BaseDatosMatriz (" & _
"[CEDULA CLIENTE]," & _
"[ID_JURIS]," & _
"[ID_ESP]," & _
"[TIPO DE PROCESO]," & _
"[RADICADO]," & _
"[DEMANDANTES]," & _
"[DEMANDADOS]," & _
"[CAUSANTE]," & _
"[CURADOR]," & _
"[FECHA_DE_REGISTRO]," & _
"[NUMERO CARPETA]," & _
"[CAJA]," & _
"[NOTAS]," & _
"[APDE_DEMANDANTES]," & _
"[APDE_DEMANDADOS]," & _
"[FECHA_FIN])"

strSQL = strSQL & _
"values( " & _
Me.CEDULA_CLIENTE & ", " & _
Me.ID_JURIS & ", " & _
Me.ID_ESP & ", " & _
Me.TIPO_DE_PROCESO & ", " & _
Me.RADICADO & ", " & _
Me.DEMANDANTES & ", " & _
Me.DEMANDADOS & ", " & _
Me.CAUSANTE & ", " & _
Me.CURADOR & ", " & _
Me.FECHA_DE_REGISTRO & ", " & _
Me.NUMERO_CARPETA & ", " & _
Me.CAJA & ", " & _
Me.NOTAS & ", " & _
Me.APDE_DEMANDANTES & ", " & _
Me.APDE_DEMANDADOS & ", " & _
Me.FECHA_FIN & ");"
Set db = CurrentDb()

db.Execute strSQL
db.Close
note: all fields are text and two dates mm / dd / yyyy

EDDY
3 Weeks Ago #10

P: 8
Estas son las dos fechas: Gracias
[fecha_de_registro]," & _
" [fecha_fi
3 Weeks Ago #11

P: 8
ESTAS SON LAS FECHAS, GRACIAS

ME.FECHA_DE_REGISTRO & "," & _
Me.FECHA_FIN &")
3 Weeks Ago #12

P: 8
[fecha_de_registro], "& _
" [fecha_fin])"
3 Weeks Ago #13

ADezii
Expert 5K+
P: 8,741
Try the following adjustment ([FECHA_DE_REGISTRO] & [FECHA_FIN] are Dates):
Expand|Select|Wrap|Line Numbers
  1. '***** SOME CODE INTENTIONALLY OMITTED *****
  2. strSQL = strSQL & _
  3.          " VALUES('" & _
  4.          Me.CEDULA_CLIENTE & "', '" & _
  5.          Me.ID_JURIS & "', '" & _
  6.          Me.ID_ESP & "', '" & _
  7.          Me.TIPO_DE_PROCESO & "', '" & _
  8.          Me.RADICADO & "', '" & _
  9.          Me.DEMANDANTES & "', '" & _
  10.          Me.DEMANDADOS & "', '" & _
  11.          Me.CAUSANTE & "', '" & _
  12.          Me.CURADOR & "', #" & _
  13.          Me.FECHA_DE_REGISTRO & "#, '" & _
  14.          Me.NUMERO_CARPETA & "', '" & _
  15.          Me.CAJA & "', '" & _
  16.          Me.NOTAS & "', '" & _
  17.          Me.APDE_DEMANDANTES & "', '" & _
  18.          Me.APDE_DEMANDADOS & "', #" & _
  19.          Me.FECHA_FIN & "#);"
  20. '***** SOME CODE INTENTIONALLY OMITTED *****
3 Weeks Ago #14

P: 8
Thank you ADezii. That worked! Eureka !, Eureka !, Thank God and you. I have also been retired for 20 years, 3 months ago I have been learning Access, to make a legal system for my brother-in-law. Well thank you very much. God bless you.
3 Weeks Ago #15

ADezii
Expert 5K+
P: 8,741
You are quite welcome and bless you also. Good Luck with your Project and stay safe.
3 Weeks Ago #16

Post your reply

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