Copy record within the same table by changing some fields

Asked

Viewed 69 times

3

I am trying to copy a record from the table to a new record changing some fields, but still this with error and can not locate, it is possible to see where I made the mistake, follows below the lines of programming.

Dim strQtde As Integer, I As Byte
On Error GoTo Erro
        If MsgBox("Confirma copia do registro?", vbYesNo + vbQuestion, "Atenção!") = True Then            Set rsMov = currentdb.OpenRecordset("DEVOLUÇÕES1")
            For I = 1 To strQtde
                rsMov.AddNew
                    rsMov("Aluno") = Me. Aluno
                    rsMov("Série") = Me. Série
                    rsMov("N_Tombo") = Me. N_Tombo
                    rsMov("Livro") = Me. Livro
                    rsMov("Data Retirada") =DateAdd("m", I, Me. Data Retirada)
                    rsMov("Data Dev") =DateAdd("m", I, Me. Data Dev)
                    rsMov("Periodo") = Me. Periodo
                    rsMov("Situação") = Me. Situação
                    rsMov("Penalidade Até") = Me. Penalidade Até
                    rsMov("PENALIDADE") = Me. PENALIDADE
                    rsMov("Observação") = Me. Observação
                    rsMov("Telefone") = Me. Telefone
                    rsMov("Celular") = Me. Celular
                    rsMov("RETIRADA") = Me. RETIRADA
                    rsMov("CONSULTA") = Me. CONSULTA
                    rsMov("Livros_") = Me. Livros_
                    rsMov("Revista") = Me. Revista
                    rsMov("TCC") = Me. TCC
                    rsMov("Outros") = Me. Outros
                    rsMov("Renovação") = Me. Renovação
                    rsMov("EMAIL") = Me. EMAIL
                    rsMov("Ficha    ") = Me. Ficha
                    rsMov("Data do Cadastro") = Me. Data do Cadastro
                    rsMov.Update
            Next I
            MsgBox "Registro renovado com sucesso.", vbInformation, strTitulo & strVersao
           Set rsMov = Nothing
        Else
            MsgBox "Operação cancelada.", vbInformation, "Atenção!!"
            Exit Sub
        End If

Sai:
    Set rsMov = Nothing
    Exit Sub
Erro:
    MsgBox "Erro ao renovar título.", vbInformation, "Atenção!!"
    Resume Sai

The system says an IF is missing, please ask for help.

1 answer

1

Mauro, the IF line is with commands after THEN, that is, that IF ends on this same line, so the END IF below does not recognize this IF.

To solve the problem, move the back of the THEN to the bottom line, as I did in the code part below. That’s it:

    If MsgBox("Confirma copia do registro?", vbYesNo + vbQuestion, "Atenção!") = True Then 

     Set rsMov = currentdb.OpenRecordset("DEVOLUÇÕES1")

     ...
     ...
     ...
  • Hi Mauro, the answer served to you friend? If yes, please mark the answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.