Selasa, 22 November 2022

Re: [MSAccessProfessionals] Save report with First_Name & Last_Name in PDF format

Hi Lou,

I have removed a lot of the extra copies of the same comments in this reply for ease of review. It isn't clear if you have tried setting a break point near the top of your code and stepping through. Also, adding some debug.Print lines in your code will help understand memory variables.


It might be an issue the record hasn't been saved prior to the code running.


Duane


On Mon, Nov 21, 2022 at 04:16 AM, Duane Hookom wrote:

 

I would try basic troubleshooting using a combination of breakpoints and debug.print to see what is going on with your code.  

  

Duane 

 

On Sun, Nov 20, 2022 at 06:41 AM, Giorgio Rovelli wrote: 

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? 

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 String 

Dim strWhere As String 

Dim strFilter As String 

Dim strInputFileName As String 

Dim strTitle As String 

Dim strSaveName As String 

strDocName = "Rel_View_Data_Rpt" 

    strWhere = "(ID)=" & Me!ID 

    DoCmd.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 SaveFileName 

strSaveFileName = ahtCommonFileOpenSave( _ 

OpenFile:=False, _ 

Filter:=strFilter, _ 

FileName:=strSaveName & "_" & Me.[Last_Name] & ".pdf", DialogTitle:=strTitle, _ 

Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_PATHMUSTEXIST) 

If Len(strSaveFileName) = 0 Then 

 DoCmd.Close acReport, strDocName, acSaveNo 

Exit Sub 

End If 

  DoCmd.OutputTo acOutputReport, strDocName, acFormatPDF, strSaveFileName 

  

  DoCmd.Close acReport, strDocName, acSaveNo 

   

MsgBox Me.[First_Name] & " " & Me.[Last_Name] & " Report saved in PFD Format." 

   

End Sub 

 

Re: [MSAccessProfessionals] Save report with First_Name & Last_Name in PDF format

On Mon, Nov 21, 2022 at 04:16 AM, Duane Hookom wrote:
I would try basic troubleshooting using a combination of breakpoints and debug.print to see what is going on with your code. 
 
Duane

Sent from my mobile

On Nov 21, 2022, at 1:29 AM, LOU(at home) <lou@ix.net.au> wrote:
On Sun, Nov 20, 2022 at 06:41 AM, Giorgio Rovelli wrote:
<!doctype html>

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 String
Dim strWhere As String
Dim strFilter As String
Dim strInputFileName As String
Dim strTitle As String
Dim strSaveName As String
 
 
strDocName = "Rel_View_Data_Rpt"
 
    strWhere = "(ID)=" & Me!ID
    DoCmd.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 SaveFileName
strSaveFileName = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strFilter, _
FileName:=strSaveName & "_" & Me.[Last_Name] & ".pdf", DialogTitle:=strTitle, _
Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_PATHMUSTEXIST)
If Len(strSaveFileName) = 0 Then
 DoCmd.Close acReport, strDocName, acSaveNo
Exit Sub
End If
  DoCmd.OutputTo acOutputReport, strDocName, acFormatPDF, strSaveFileName
 
  DoCmd.Close acReport, strDocName, acSaveNo
  
MsgBox Me.[First_Name] & " " & Me.[Last_Name] & " Report saved in PFD Format."
  
End Sub

 On Sun, Nov 20, 2022 at 06:41 AM, Giorgio Rovelli wrote:
<!doctype html>

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 String
Dim strWhere As String
Dim strFilter As String
Dim strInputFileName As String
Dim strTitle As String
Dim strSaveName As String
 
 
strDocName = "Rel_View_Data_Rpt"
 
    strWhere = "(ID)=" & Me!ID
    DoCmd.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 SaveFileName
strSaveFileName = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strFilter, _
FileName:=strSaveName & "_" & Me.[Last_Name] & ".pdf", DialogTitle:=strTitle, _
Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_PATHMUSTEXIST)
If Len(strSaveFileName) = 0 Then
 DoCmd.Close acReport, strDocName, acSaveNo
Exit Sub
End If
  DoCmd.OutputTo acOutputReport, strDocName, acFormatPDF, strSaveFileName
 
  DoCmd.Close acReport, strDocName, acSaveNo
  
MsgBox Me.[First_Name] & " " & Me.[Last_Name] & " Report saved in PFD Forma
End Sub
Thank you Georgio, but that gave me no joy! :(

Playing around last night I found that if I deleted these lines:

If Len(strSaveFileName) = 0 Then
 DoCmd.Close acReport, strDocName, acSaveNo
Exit Sub
End If
it worked except that the save file name was the name of the Report ( "Rel_View_Data_Rpt") and not the name of the person in the Report: (Me.[First_Name] & " " & Me.[Last_Name])
Any suggestions to get around this so that the default file save name is the First_Name  & Last_Name of the person would be welcomed.
Thank you,
Lou

 


 

 On Mon, Nov 21, 2022 at 04:16 AM, Duane Hookom wrote:
I would try basic troubleshooting using a combination of breakpoints and debug.print to see what is going on with your code. 
 
Duane

Sent from my mobile

On Nov 21, 2022, at 1:29 AM, LOU(at home) <lou@ix.net.au> wrote:
On Sun, Nov 20, 2022 at 06:41 AM, Giorgio Rovelli wrote:
<!doctype html>

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 String
Dim strWhere As String
Dim strFilter As String
Dim strInputFileName As String
Dim strTitle As String
Dim strSaveName As String
 
 
strDocName = "Rel_View_Data_Rpt"
 
    strWhere = "(ID)=" & Me!ID
    DoCmd.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 SaveFileName
strSaveFileName = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strFilter, _
FileName:=strSaveName & "_" & Me.[Last_Name] & ".pdf", DialogTitle:=strTitle, _
Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_PATHMUSTEXIST)
If Len(strSaveFileName) = 0 Then
 DoCmd.Close acReport, strDocName, acSaveNo
Exit Sub
End If
  DoCmd.OutputTo acOutputReport, strDocName, acFormatPDF, strSaveFileName
 
  DoCmd.Close acReport, strDocName, acSaveNo
  
MsgBox Me.[First_Name] & " " & Me.[Last_Name] & " Report saved in PFD Format."
  
End Sub

 On Sun, Nov 20, 2022 at 06:41 AM, Giorgio Rovelli wrote:
<!doctype html>

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 String
Dim strWhere As String
Dim strFilter As String
Dim strInputFileName As String
Dim strTitle As String
Dim strSaveName As String
 
 
strDocName = "Rel_View_Data_Rpt"
 
    strWhere = "(ID)=" & Me!ID
    DoCmd.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 SaveFileName
strSaveFileName = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strFilter, _
FileName:=strSaveName & "_" & Me.[Last_Name] & ".pdf", DialogTitle:=strTitle, _
Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_PATHMUSTEXIST)
If Len(strSaveFileName) = 0 Then
 DoCmd.Close acReport, strDocName, acSaveNo
Exit Sub
End If
  DoCmd.OutputTo acOutputReport, strDocName, acFormatPDF, strSaveFileName
 
  DoCmd.Close acReport, strDocName, acSaveNo
  
MsgBox Me.[First_Name] & " " & Me.[Last_Name] & " Report saved in PFD Forma
End Sub
Thank you Georgio, but that gave me no joy! :(

Playing around last night I found that if I deleted these lines:

If Len(strSaveFileName) = 0 Then
 DoCmd.Close acReport, strDocName, acSaveNo
Exit Sub
End If
it worked except that the save file name was the name of the Report ( "Rel_View_Data_Rpt") and not the name of the person in the Report: (Me.[First_Name] & " " & Me.[Last_Name])
Any suggestions to get around this so that the default file save name is the First_Name  & Last_Name of the person would be welcomed.
Thank you,
Lou

 


Still needing help with this :(       Regards, Lou

 
 
_._,_._,_

Groups.io Links:

You receive all messages sent to this group.

View/Reply Online (#116324) | Reply To Group | Reply To Sender | Mute This Topic | New Topic
Your Subscription | Contact Group Owner | Unsubscribe [sugeng.panjalu.access@blogger.com]

_._,_._,_

Senin, 21 November 2022

Re: [MSAccessProfessionals] Save report with First_Name & Last_Name in PDF format

I would try basic troubleshooting using a combination of breakpoints and debug.print to see what is going on with your code. 

Duane

Sent from my mobile

On Nov 21, 2022, at 1:29 AM, LOU(at home) <lou@ix.net.au> wrote:

On Sun, Nov 20, 2022 at 06:41 AM, Giorgio Rovelli wrote:
<!doctype html>

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 String
Dim strWhere As String
Dim strFilter As String
Dim strInputFileName As String
Dim strTitle As String
Dim strSaveName As String
 
 
strDocName = "Rel_View_Data_Rpt"
 
    strWhere = "(ID)=" & Me!ID
    DoCmd.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 SaveFileName
strSaveFileName = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strFilter, _
FileName:=strSaveName & "_" & Me.[Last_Name] & ".pdf", DialogTitle:=strTitle, _
Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_PATHMUSTEXIST)
If Len(strSaveFileName) = 0 Then
 DoCmd.Close acReport, strDocName, acSaveNo
Exit Sub
End If
  DoCmd.OutputTo acOutputReport, strDocName, acFormatPDF, strSaveFileName
 
  DoCmd.Close acReport, strDocName, acSaveNo
  
MsgBox Me.[First_Name] & " " & Me.[Last_Name] & " Report saved in PFD Format."
  
End Sub

 On Sun, Nov 20, 2022 at 06:41 AM, Giorgio Rovelli wrote:
<!doctype html>

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 String
Dim strWhere As String
Dim strFilter As String
Dim strInputFileName As String
Dim strTitle As String
Dim strSaveName As String
 
 
strDocName = "Rel_View_Data_Rpt"
 
    strWhere = "(ID)=" & Me!ID
    DoCmd.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 SaveFileName
strSaveFileName = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strFilter, _
FileName:=strSaveName & "_" & Me.[Last_Name] & ".pdf", DialogTitle:=strTitle, _
Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_PATHMUSTEXIST)
If Len(strSaveFileName) = 0 Then
 DoCmd.Close acReport, strDocName, acSaveNo
Exit Sub
End If
  DoCmd.OutputTo acOutputReport, strDocName, acFormatPDF, strSaveFileName
 
  DoCmd.Close acReport, strDocName, acSaveNo
  
MsgBox Me.[First_Name] & " " & Me.[Last_Name] & " Report saved in PFD Forma
End Sub
Thank you Georgio, but that gave me no joy! :(

Playing around last night I found that if I deleted these lines:

If Len(strSaveFileName) = 0 Then
 DoCmd.Close acReport, strDocName, acSaveNo
Exit Sub
End If
it worked except that the save file name was the name of the Report ( "Rel_View_Data_Rpt") and not the name of the person in the Report: (Me.[First_Name] & " " & Me.[Last_Name])
Any suggestions to get around this so that the default file save name is the First_Name  & Last_Name of the person would be welcomed.
Thank you,
Lou

 


 

Minggu, 20 November 2022

Re: [MSAccessProfessionals] Save report with First_Name & Last_Name in PDF format

On Sun, Nov 20, 2022 at 06:41 AM, Giorgio Rovelli wrote:
<!doctype html>

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 String
Dim strWhere As String
Dim strFilter As String
Dim strInputFileName As String
Dim strTitle As String
Dim strSaveName As String
 
 
strDocName = "Rel_View_Data_Rpt"
 
    strWhere = "(ID)=" & Me!ID
    DoCmd.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 SaveFileName
strSaveFileName = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strFilter, _
FileName:=strSaveName & "_" & Me.[Last_Name] & ".pdf", DialogTitle:=strTitle, _
Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_PATHMUSTEXIST)
If Len(strSaveFileName) = 0 Then
 DoCmd.Close acReport, strDocName, acSaveNo
Exit Sub
End If
  DoCmd.OutputTo acOutputReport, strDocName, acFormatPDF, strSaveFileName
 
  DoCmd.Close acReport, strDocName, acSaveNo
  
MsgBox Me.[First_Name] & " " & Me.[Last_Name] & " Report saved in PFD Format."
  
End Sub

 On Sun, Nov 20, 2022 at 06:41 AM, Giorgio Rovelli wrote:
<!doctype html>

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 String
Dim strWhere As String
Dim strFilter As String
Dim strInputFileName As String
Dim strTitle As String
Dim strSaveName As String
 
 
strDocName = "Rel_View_Data_Rpt"
 
    strWhere = "(ID)=" & Me!ID
    DoCmd.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 SaveFileName
strSaveFileName = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strFilter, _
FileName:=strSaveName & "_" & Me.[Last_Name] & ".pdf", DialogTitle:=strTitle, _
Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_PATHMUSTEXIST)
If Len(strSaveFileName) = 0 Then
 DoCmd.Close acReport, strDocName, acSaveNo
Exit Sub
End If
  DoCmd.OutputTo acOutputReport, strDocName, acFormatPDF, strSaveFileName
 
  DoCmd.Close acReport, strDocName, acSaveNo
  
MsgBox Me.[First_Name] & " " & Me.[Last_Name] & " Report saved in PFD Forma
End Sub
Thank you Georgio, but that gave me no joy! :(

Playing around last night I found that if I deleted these lines:

If Len(strSaveFileName) = 0 Then
 DoCmd.Close acReport, strDocName, acSaveNo
Exit Sub
End If
it worked except that the save file name was the name of the Report ( "Rel_View_Data_Rpt") and not the name of the person in the Report: (Me.[First_Name] & " " & Me.[Last_Name])
Any suggestions to get around this so that the default file save name is the First_Name  & Last_Name of the person would be welcomed.
Thank you,
Lou

 


 
_._,_._,_

Groups.io Links:

You receive all messages sent to this group.

View/Reply Online (#116322) | Reply To Group | Reply To Sender | Mute This Topic | New Topic
Your Subscription | Contact Group Owner | Unsubscribe [sugeng.panjalu.access@blogger.com]

_._,_._,_

Re: [MSAccessProfessionals] Save report with First_Name & Last_Name in PDF format

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 String
Dim strWhere As String
Dim strFilter As String
Dim strInputFileName As String
Dim strTitle As String
Dim strSaveName As String


strDocName = "Rel_View_Data_Rpt"

    strWhere = "(ID)=" & Me!ID
    DoCmd.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 SaveFileName
strSaveFileName = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strFilter, _
FileName:=strSaveName & "_" & Me.[Last_Name] & ".pdf", DialogTitle:=strTitle, _
Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_PATHMUSTEXIST)
If Len(strSaveFileName) = 0 Then
 DoCmd.Close acReport, strDocName, acSaveNo
Exit Sub
End If
  DoCmd.OutputTo acOutputReport, strDocName, acFormatPDF, strSaveFileName

  DoCmd.Close acReport, strDocName, acSaveNo
  
MsgBox Me.[First_Name] & " " & Me.[Last_Name] & " Report saved in PFD Format."
  
End Sub

[MSAccessProfessionals] Save report with First_Name & Last_Name in PDF format

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 String
Dim strWhere As String
Dim strFilter As String
Dim strInputFileName As String
Dim strTitle As String
Dim strSaveName As String
 
 
strDocName = "Rel_View_Data_Rpt"
 
    strWhere = "(ID)=" & Me!ID
    DoCmd.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 SaveFileName
strSaveFileName = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strFilter, _
FileName:=strSaveName & "_" & Me.[Last_Name] & ".pdf", DialogTitle:=strTitle, _
Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_PATHMUSTEXIST)
If Len(strSaveFileName) = 0 Then
 DoCmd.Close acReport, strDocName, acSaveNo
Exit Sub
End If
  DoCmd.OutputTo acOutputReport, strDocName, acFormatPDF, strSaveFileName
 
  DoCmd.Close acReport, strDocName, acSaveNo
  
MsgBox Me.[First_Name] & " " & Me.[Last_Name] & " Report saved in PFD Format."
  
End Sub
_._,_._,_

Groups.io Links:

You receive all messages sent to this group.

View/Reply Online (#116320) | Reply To Group | Reply To Sender | Mute This Topic | New Topic
Your Subscription | Contact Group Owner | Unsubscribe [sugeng.panjalu.access@blogger.com]

_._,_._,_