Question:
I'm trying to copy a record from the table to a new record by changing some fields, but it's still in error and I can't find it, you can see where I made the mistake, below are the programming lines.
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 there is an IF missing, I ask for help please.
Answer:
Mauro, the IF line has commands after the THEN, that is, this IF ends on 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 next piece of code. That's it:
If MsgBox("Confirma copia do registro?", vbYesNo + vbQuestion, "Atenção!") = True Then
Set rsMov = currentdb.OpenRecordset("DEVOLUÇÕES1")
...
...
...