Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2012
    Posts
    126

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

    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.

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    If I understand you correctly, I'd try using

    Code:
    DoCmd.OpenReport "rpt" & ListBoxForReports, acNormal


    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Aug 2012
    Posts
    126
    Thank you again linq

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Glad we could help!

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •