error 3061 como solvento este error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • EddyBohorquez
    New Member
    • Sep 2020
    • 10

    error 3061 como solvento este error

    al ejecutar

    Code:
    db.Execute "INSERT INTO BaseDatosMatriz" _
        & "([CEDULA CLIENTE],[ID_JURIS],[ID_ESP],[TIPO DE PROCESO],[RADICADO]," _
        & "[DEMANDATES],[DEMANDADOS],[CAUSANTE],[CURADOR],[FECHA_DE_REGISTRO]," _
        & "[NUMERO CARPETA],[CAJA],[NOTAS],[APDE_DEMANDANTES],[APDE_DEMANDADOS],[FECHA_FIN])" _
        & "values( Form![CEDULA CLIENTE],Form![ID_JURIS],Form![ID_ESP],Form![TIPO DE PROCESO],Form![RADICADO]," _
        & "Form![DEMANDATES],Form![DEMANDADOS],Form![CAUSANTE],Form![CURADOR],Form![FECHA_DE_REGISTRO]," _
        & "Form![NUMERO CARPETA],Form![CAJA],Form![NOTAS],Form![APDE_DEMANDANTES],Form[APDE_DEMANDADOS],Form![FECHA_FIN]);"
    
    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
    Last edited by twinnyfo; Sep 3 '20, 12:20 PM. Reason: Code tags, formatting, translating into English.
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3665

    #2
    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 txtCedulaClient e. 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:

    Code:
    Option Explicit
    Option Compare Database
    
    Private Sub YourSubName()
        Dim strSQL As String
        Dim db As DAO.Database
    
        strSQL = _
            "INSERT INTO BaseDatosMatriz (" & _
                "[CEDULA CLIENTE], " & _
                "[ID_JURIS], " & _
                "[ID_ESP], " & _
                "[TIPO DE PROCESO], " & _
                "[RADICADO], " & _
                "[DEMANDATES], " & _
                "[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.[DEMANDATES] & ", " & _
                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
        db.Close
    
    End Sub
    Hope this hepps!

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #3
      My guess would be that you are not Delimiting Text Fields:
      Code:
      Dim strSQL As String
      Dim strFName As String
      Dim strLName As String
      Dim lngZip As Long
      Dim db As DAO.Database
      
      strFName = "A"
      strLName = "Dezii"
      lngZip = 9999
      
      strSQL = "INSERT INTO Employees([First Name],[Last Name],[Zip]) VALUES('" & strFName & "','" & _
                                       strLName & "'," & lngZip & ");"
      Set db = CurrentDb
      
      db.Execute strSQL, dbFailOnError
      
      db.Close
      Set db = Nothing

      Comment

      • twinnyfo
        Recognized Expert Moderator Specialist
        • Nov 2011
        • 3665

        #4
        ADezii,

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

        Always keeping me on my toes!

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          @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.

          Comment

          • EddyBohorquez
            New Member
            • Sep 2020
            • 10

            #6
            Error de INSERT INTO

            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_REGIST RO]," & _
            "[NUMERO CARPETA]," & _
            "[CAJA]," & _
            "[NOTAS]," & _
            "[APDE_DEMANDANTE S]," & _
            "[APDE_DEMANDADOS]," & _
            "[FECHA_FIN])"

            strSQL = strSQL & _
            "values( " & _
            Me.CEDULA_CLIEN TE & ", " & _
            Me.ID_JURIS & ", " & _
            Me.ID_ESP & ", " & _
            Me.TIPO_DE_PROC ESO & ", " & _
            Me.RADICADO & ", " & _
            Me.DEMANDANTES & ", " & _
            Me.DEMANDADOS & ", " & _
            Me.CAUSANTE & ", " & _
            Me.CURADOR & ", " & _
            Me.FECHA_DE_REG ISTRO & ", " & _
            Me.NUMERO_CARPE TA & ", " & _
            Me.CAJA & ", " & _
            Me.NOTAS & ", " & _
            Me.APDE_DEMANDA NTES & ", " & _
            Me.APDE_DEMANDA DOS & ", " & _
            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

            Comment

            • ADezii
              Recognized Expert Expert
              • Apr 2006
              • 8834

              #7
              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.

              Comment

              • EddyBohorquez
                New Member
                • Sep 2020
                • 10

                #8
                error 3061 como solvento este error

                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_REGIST RO]," & _
                "[NUMERO CARPETA]," & _
                "[CAJA]," & _
                "[NOTAS]," & _
                "[APDE_DEMANDANTE S]," & _
                "[APDE_DEMANDADOS]," & _
                " [FECHA_FIN]) "

                strSQL = strSQL & _
                " valores ("& _
                Me.CEDULA_CLIEN TE &", "& _
                Me.ID_JURIS &", "& _
                Me.ID_ESP &", "& _
                Me.TIPO_DE_PROC ESO &", " & _
                Yo.RADICADO & "," & _
                Yo.DEMANDANTES & ", "& _
                Me.DEMANDADOS &", "& _
                Me.CAUSANTE &", "& _
                Me.CURADOR &", "& _
                Yo.FECHA_DE_REG ISTRO & "," & _
                Yo.NUMERO_CARPE TA & "," & _
                Yo.CAJA & "," & _
                Yo.NOTAS & "," & _
                Yo.APDE_DEMANDA NTES & "," & _
                Yo.APDE_DEMANDA DOS & " , "& _
                Me.FECHA_FIN &"); "
                Set db = CurrentDb ()

                db.Execute strSQL
                db.Close

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

                EDDY

                Comment

                • ADezii
                  Recognized Expert Expert
                  • Apr 2006
                  • 8834

                  #9
                  What two Fields are the Date Fields?

                  Comment

                  • EddyBohorquez
                    New Member
                    • Sep 2020
                    • 10

                    #10
                    error 3061 como solvento este error

                    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_REGIST RO]," & _
                    "[NUMERO CARPETA]," & _
                    "[CAJA]," & _
                    "[NOTAS]," & _
                    "[APDE_DEMANDANTE S]," & _
                    "[APDE_DEMANDADOS]," & _
                    "[FECHA_FIN])"

                    strSQL = strSQL & _
                    "values( " & _
                    Me.CEDULA_CLIEN TE & ", " & _
                    Me.ID_JURIS & ", " & _
                    Me.ID_ESP & ", " & _
                    Me.TIPO_DE_PROC ESO & ", " & _
                    Me.RADICADO & ", " & _
                    Me.DEMANDANTES & ", " & _
                    Me.DEMANDADOS & ", " & _
                    Me.CAUSANTE & ", " & _
                    Me.CURADOR & ", " & _
                    Me.FECHA_DE_REG ISTRO & ", " & _
                    Me.NUMERO_CARPE TA & ", " & _
                    Me.CAJA & ", " & _
                    Me.NOTAS & ", " & _
                    Me.APDE_DEMANDA NTES & ", " & _
                    Me.APDE_DEMANDA DOS & ", " & _
                    Me.FECHA_FIN & ");"
                    Set db = CurrentDb()

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

                    EDDY

                    Comment

                    • EddyBohorquez
                      New Member
                      • Sep 2020
                      • 10

                      #11
                      error 3061 como solvento este error

                      Estas son las dos fechas: Gracias
                      [fecha_de_regist ro]," & _
                      " [fecha_fi

                      Comment

                      • EddyBohorquez
                        New Member
                        • Sep 2020
                        • 10

                        #12
                        error 3061 como solvento este error

                        ESTAS SON LAS FECHAS, GRACIAS

                        ME.FECHA_DE_REG ISTRO & "," & _
                        Me.FECHA_FIN &")

                        Comment

                        • EddyBohorquez
                          New Member
                          • Sep 2020
                          • 10

                          #13
                          error 3061 como solvento este error

                          [fecha_de_regist ro], "& _
                          " [fecha_fin])"

                          Comment

                          • ADezii
                            Recognized Expert Expert
                            • Apr 2006
                            • 8834

                            #14
                            Try the following adjustment ([FECHA_DE_REGIST RO] & [FECHA_FIN] are Dates):
                            Code:
                            '***** SOME CODE INTENTIONALLY OMITTED *****
                            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 & "#);"
                            '***** SOME CODE INTENTIONALLY OMITTED *****

                            Comment

                            • EddyBohorquez
                              New Member
                              • Sep 2020
                              • 10

                              #15
                              error 3061 como solvento este error

                              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.

                              Comment

                              Working...