Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Temporarely Copy and Rename a Report 1

Status
Not open for further replies.

Xiphiaz

Programmer
Dec 29, 2003
33
NL
Hi,

Maybe a strange question, but I want temporarely copy and rename one of my reports and then delete it again via a button on my form.

The reason for this is that I use Bullzip to print to the report to PDF. (Bullzip can save the PDF with the same name as the report without any input from me, but I would like to use a specified Field name for those files.

Temporarely copying or renaming the report to the Field name I prefer will be the solution, but I can't find anything about this.

Any help will be appriciated.

BTW. I know there are other ways to print to PDF, but that all look quite complicated for me. (I'm not an expert [sadeyes])

Thank you
 
Code:
Sub rptCopy(strRpt As String, newName As String)
  'On Error GoTo ErrCopyRpt
  DoCmd.CopyObject , newName, acReport, strRpt
  Exit Sub
ErrCopyRpt:
  Select Case Err
    Case 2501
      'Cancel Selected in Dialog Box
    Case 2544
      'Report does not exist
      MsgBox strRpt & " is not a valid report name.", vbCritical, "Save Problem"
    Case Else
      MsgBox Err & ":-" & vbCrLf & Err.Description, , "Save Problem"
  End Select
End Sub

Sub rptSaveAs(strRpt As String)
  On Error GoTo ErrSaveAs
  DoCmd.SelectObject acReport, strRpt, True
  DoCmd.RunCommand acCmdSaveAs
  Exit Sub
ErrSaveAs:
  Select Case Err
    Case 2501
      'Cancel Selected in Dialog Box
    Case 2544
      'Report does not exist
      MsgBox strRpt & " is not a valid report name.", vbCritical, "Save Problem"
    Case Else
      MsgBox Err & ":-" & vbCrLf & Err.Description, , "Save Problem"
  End Select
End Sub

Sub rptDelete(strRpt As String)
  On Error GoTo ErrDelete
  DoCmd.SelectObject acReport, strRpt, True
  DoCmd.RunCommand acCmdDelete
  Exit Sub
ErrDelete:
  Select Case Err
    Case 2501
      'Cancel Selected in Dialog Box
    Case 2544
      'Report does not exist
      MsgBox strRpt & " is not a valid report name.", vbCritical, "Save Problem"
    Case Else
      MsgBox Err & ":-" & vbCrLf & Err.Description, , "Save Problem"
  End Select
End Sub
 
The error messages did to be adjusted since I did a copy and paste.
 
Let me say that one more time since I do not type or speak well;

You need to fix the error messages. I did a copy and paste from the saveas method for the other two procedures. You do not need the rptSaveAs method, but I provided it in case you want that functionality.
 
Thank you very much for your help.
This does work, but at the end I do get a error message.

But I also found that the PDF name is not generated from the report name, but from the CAPTION of the report.

Do you know if I can change this to a certain field when opening the report?


Thanks

 
on the on open event
Code:
Private Sub Report_Open(Cancel As Integer)
  Me.Caption = "put some code here"
End Sub

Since you want to change this prior to opening the report you could in the "put some code here":
reference a control on a form
a public variable
or a function like a message box that returns a value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top