Assign a title to a report through VB

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Eugenio
    New Member
    • Mar 2008
    • 13

    #1

    Assign a title to a report through VB

    Hello everybody, I'm new to this forum, so sorry if i post something that has been already answered althought i couldn't find it in search. Anyway, there it goes:

    i have a search system which gives you the values you search for in a list box. The list box has its "Multi Select" property set to "Extended" which allows you to pick specific records from the list box. I also have a button to allow you to produce a report based on the values u've selected from the list box. the button is based on a sub and a function, here is the code for both:

    Function :

    Private Function GetCriteria() As String
    Dim stDocCriteria As String
    Dim VarItm As Variant
    For Each VarItm In lstContList.Ite msSelected
    stDocCriteria = stDocCriteria & "[LifeID] = " & lstContList.Col umn(0, VarItm) & " OR "
    Next
    If stDocCriteria <> "" Then
    stDocCriteria = Left(stDocCrite ria, Len(stDocCriter ia) - 4)
    Else
    stDocCriteria = "True"
    End If
    GetCriteria = stDocCriteria
    End Function

    Button to execute the function :

    Private Sub cmdRpt_Click()
    DoCmd.OpenRepor t "rptContLif e", acPreview, , GetCriteria()
    End Sub

    So the question is: Since I only have 1 query and 1 report in my system and I want to keep it this way, can i assign a title to the report by clicking the button? Either through a list of pre-typed titles or a manual input. The way I picture it is basicly you select the values you need from the list box, press the button, a input box comes up asking you to input the report title, you input "Values I want" and you get a report generated with the title "Values I want"

    Is this possible?

    Looking forward to your answer,
    Yours truly novice access user.

    p.s. im in access 2007
  • MikeTheBike
    Recognized Expert Contributor
    • Jun 2007
    • 640

    #2
    Hi

    You could try assigning the input "Values I want" to a hidden Textbox control on the form before the report is opened and link the reports Title Textbox control back the hidden Textbox on the form that launches it (assuming that this form remains open or hidden while the report is open).

    HTH ?

    MTB

    Comment

    • Eugenio
      New Member
      • Mar 2008
      • 13

      #3
      But i need the user to be able to input any report title they want. They wont be able to change the values in the hidden text box. and im not really sure how to link a text box with a caption, or is it now what u mean ? ;)

      Comment

      • Eugenio
        New Member
        • Mar 2008
        • 13

        #4
        got it. topic closed.

        Comment

        Working...