Did you set strFilter? Do you have *'s in the First_Name field? Maybe you should specify strWhere when you use DoCmd.OutputTo as well?
On 11/20/2022 10:26 AM LOU(at home) <lou@ix.net.au> wrote:
Hello all, I haven't posted on here for many years! I'm now 76 years old and the old grey matter is slowing down :(
Today I went back to a database I first worked on 15 or so years ago with Access 97 I think.
I've now subscribed to Access 365 and found a few things no working, I've fixed a couple but this one has me stumped.
The code below belongs to a Button which when clicked would open allow me to save a record in pdf format and the default name of the file would be the First_Name & Last_Name of the open record.
When I click on it now, nothing happens!
Any help would be greatly appreciated.
Thank you, Lou
------------------------------
Private Sub Save_PDF_Button_Click()Dim strDocName As StringDim strWhere As StringDim strFilter As StringDim strInputFileName As StringDim strTitle As StringDim strSaveName As String
strDocName = "Rel_View_Data_Rpt"
strWhere = "(ID)=" & Me!IDDoCmd.OpenReport strDocName, acViewPreview, , strWhere
strTitle = "Save Report for " & Me.First_Name & "_" & Me.Last_Name & " in PDF Format" & " © Lou Lucano"strSaveName = Replace(Me.First_Name, "*", "")'Ask for SaveFileNamestrSaveFileName = ahtCommonFileOpenSave( _OpenFile:=False, _Filter:=strFilter, _FileName:=strSaveName & "_" & Me.[Last_Name] & ".pdf", DialogTitle:=strTitle, _Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_PATHMUSTEXIST)If Len(strSaveFileName) = 0 ThenDoCmd.Close acReport, strDocName, acSaveNoExit SubEnd IfDoCmd.OutputTo acOutputReport, strDocName, acFormatPDF, strSaveFileName
DoCmd.Close acReport, strDocName, acSaveNoMsgBox Me.[First_Name] & " " & Me.[Last_Name] & " Report saved in PFD Format."End Sub
Tidak ada komentar:
Posting Komentar