Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

List box showing my reports and a cmd button to print them

$
0
0
I have a form with a list box that lists all of my reports. I also have two cmd buttons one, one to print the report and one to view the report. In the query for the list box im using Name: Right(Table1!TextField,Len(Table1!TextField)-3) since my reports are named rptReport_One and I want it to show as Report_One. My issue is when I click my buttons it says the report name is misspelled since its looking for rptReport_One and not Report_One.

To Print
Code:


Private Sub cmdPrintReport_Click()

If Nz(Me.ListBoxForReports, "") <> "" Then
  DoCmd.OpenReport ListBoxForReports, acNormal
Else
  MsgBox ("You Must First Select a Report To Print!")
  Me.ListBoxForReports.SetFocus
End If

  Me.ListBoxForReports = Null
End Sub

To Open
Code:

Private Sub cmdOpenReport_Click()
If Nz(Me.ListBoxForReports, "") <> "" Then
    DoCmd.OpenReport ListBoxForReports, acViewReport
Else
    MsgBox ("You Must First Select a Report to Open!")
    Me.ListBoxForReports.SetFocus
End If
    Me.ListBoxForReports = Null
End Sub

Do i need to add the Right function to my code? And if so how would I do that?

The easier way is to kill the naming integrity I have and just name the reports Report_One but I really don't want to do that.

Viewing all articles
Browse latest Browse all 13329

Trending Articles