Copy record within the same table by changing some fields

3

I'm trying to copy a record from the table to a new record by changing some fields, but it still has an error and I can not find it, you can see where I made the mistake,

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 that an IF is missing, please help.

    
asked by anonymous 21.03.2016 / 03:29

1 answer

1

Mauro, the IF line has commands after THEN, ie, this IF ends in this same line, so the END IF below does not recognize this IF.

To solve the problem, pass the back to THEN to the bottom line, as I did in the following code part. This is it:

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

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

     ...
     ...
     ...
    
21.03.2016 / 12:11