Please help to correct this code to reuse it on clicking a button.
What I must correct to use this code in this, when clicking a button?:
Much obliged!
Code:
Function EmiteRecibo()
On Error GoTo EmiteRecibo_Err
Dim strArquivo As String
Dim strLocal As String
strArquivo = "Recibo" & Me!RecTId & Me!TbEntAbv & ".pdf"
'aponta para a pasta do ficheiro pdf a criar onde está a bd
strLocal = CurrentProject.Path & "\recibos\" & strArquivo
DoCmd.Close acForm, "ReciboComposiçãoF"
DoCmd.OpenQuery "1RecibosEmissaoQ", acViewNormal, acReadOnly
DoCmd.OpenQuery "2RecibosEmissaoQ", acViewNormal, acReadOnly
DoCmd.OpenReport "ReciboRelatório", acViewPreview, "", "[RecTId]=DLast(""RecTId"",""RecibosT"")", acHidden
Beep
MsgBox "O recibo foi emitido.", vbInformation, "Emissão de recibos"
DoCmd.OutputTo acOutputReport, "ReciboRelatório", acFormatPDF, strLocal
DoCmd.OpenReport "ReciboRelatório", acViewPreview, "", "[RecTId]=DLast(""RecTId"",""RecibosT"")", acHidden
EmiteRecibo_Exit:
Exit Function
EmiteRecibo_Err:
MsgBox Error$
Resume abre_Exit
End Function
What I must correct to use this code in this, when clicking a button?:
Code:
Private Sub Comando285_Click()
End Sub
Much obliged!