Met onderstaande code save ik een rapport met datum en als naam Overzicht.
Op mijn formulier heb ik evenwel 2 keuze mogelijkheden om mijn rapport te beperken: velden per Jaar en per Transactie (aankoop, verkoop...)
Nu zou ik graag saven met de evt gekozen mogelijkheid.
Als ik niks kies dan is naam: Datum en Overzicht.
Als ik jaar kies dan is naam: Datum en overzicht en waarde van veld Jaar.
Als ik Transactie kies dan is naam: Datum en overzicht en waarde van veld Transactie.
Als ik Transactie en Jaar kies dan : Datum en overzicht en waarden van velden Transactie en Jaar.
Private Sub CmdSave_Click()
If Me.FilePath = "" Or IsNull(Me.FilePath) Then
MsgBox "Kies een path!"
Exit Sub
End If
If Right(Me.FilePath, 1) <> "\" Then Me.FilePath = Me.FilePath & "\"
If Dir(FilePath, vbDirectory) = "" Then
Shell ("cmd /c mkdir """ & FilePath & """")
End If
pathName = Me.FilePath
fileName = pathName & " " & Format(Date, "yyyy-mm-dd") & " " & "Overzicht.pdf"
'fileName = pathName & " " & Format(Date, "yyyy-mm-dd") & " " & "Overzicht.pdf" & "Jaar"
'fileName = pathName & " " & Format(Date, "yyyy-mm-dd") & " " & "Overzicht.pdf" & "Transactie"
'fileName = pathName & " " & Format(Date, "yyyy-mm-dd") & " " & "Overzicht.pdf" & "Jaar" & "Transactie"
DoCmd.OutputTo acOutputReport, "rptOverzicht", acFormatPDF, fileName, , , , acExportQualityPrint
DoCmd.Close acReport, "rptOverzicht"
End Sub
Bedoeling is dus dat als ik op de save knop druk dat er dan, als er niks aangeduid is in de velden transactie en jaar, de 1é mogelijkheid van pas komt.
Als er wel iets in 1 vd velden of in allebei: de andere mogelijkheden.
Het is waarschijnlijk met if then, maar geraak er niet uit.
De vet, cursieve code toont wat ik wil.