Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2005

    Red face Unanswered: Problem with addnew (MS Access + MySQL)

    I've been looking for an answer to no avail, so here it goes.

    I'm building an app with Access as its front end and MySQL as its back end via ODBC. I'm generating bills based on orders. Simple app, really.

    Now, when I open the form (On Open event) to create the bills, I read from the order headers and assign them to the bill headers. The bills form has the header fields and the details as a subform.

    When I try to write to the bill details table, I open a recordset for the order details and check if there are no previous records; if not, then I write to the table. But when I do the AddNew, comes this error:

    -2147467259 (80004005)
    Invalid Operation

    I guessed this could be because the form hasn't written to the parent table, so I moved the procedure to the AfterUpdate event.

    This is the AfterUpdate event.
        Dim rs As New ADODB.Recordset
        Dim stSQL As String
        Dim rsOrden As New ADODB.Recordset
        Dim rsFactura As New ADODB.Recordset
        stSQL = "SELECT idOrden,idPrograma,datFechaComercial,idTipoTarifa,bytDuracion,dblPrecioUnitario FROM tblOrdenDetalle WHERE idOrden = " & Me!idOrden & ";"
        rs.Open stSQL, Application.CurrentProject.Connection, adOpenDynamic, adLockOptimistic
        Rem If there are no errors on the order details, to process
        If rs.EOF Then
            MsgBox "There are no order details!", vbCritical, "Error"
            Do While Not rs.EOF
                rsFactura.Open "tblFactDetalle", Application.CurrentProject.Connection, adOpenDynamic, adLockOptimistic
                rsFactura!idFact = Me!idFact
                rsFactura!txtPauta = Me!txtOrdenAgencia
                rsFactura!idPrograma = rs!idPrograma
                rsFactura!dblCosto = rs!dblPrecioUnitario
                rsFactura!bytDuracion = rs!bytDuracion
                rsFactura!bytNumeroSpots = rs!bytNumeroSpots
        End If
        Set rsFactura = Nothing
        Set rs = Nothing
    I tried doing an action query via application.currentproject.connection.execute and still get this error. If I go to phpMyAdmin at this point and input the INSERT query, it works.

    My best guess is that the parent record hasn't been saved up to this point, but haven't found a way to make sure it is so.
    Last edited by nvargas; 11-28-05 at 11:10.

  2. #2
    Join Date
    Feb 2005
    Any ideas? No one?

  3. #3
    Join Date
    Feb 2005
    Well, the problem was a failed index in the daughter table.

    Erased all indexes and relationships and made them again, then it worked. Thanx anyways.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts