Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2013
    Posts
    70

    Unanswered: set report title with query parameter in code

    good morning. i have googled this to my distraction. most of what i find is answers to filling a textbox in the report header from a parameter query. but i dimly remember seeing how to change the report "title" that can set as as a staic item in Property Sheet/Format/Caption.

    i would like to fill the caption field with the result of the output from a query. i have form that set the data in a query for a report:
    [Forms]![frmChooseStatus]![fraStatus]

    I open the report very sumply with a command button with this code:
    Code:
    Private Sub cmdStatusRpt_Click()
        On Error GoTo ErrHandler
    
        DoCmd.OpenReport "rptChooseStatus", acViewPreview
    
    ErrHandler:
        Exit Sub
    
    End Sub
    is there a way to put the output from "[Forms]![frmChooseStatus]![fraStatus]" in report title?

    many thnaks in advance,
    Scott

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    consider setting the openargs property of the openreport macro
    then test the openargs property inside the repot in a suitable event and set the caption accordingly. But be aware that some events fire before you can 'fiddle' with the design. think it has to be AFTER the open report. the advantage oif this approach is that, providing you test if there is a suitable value of openargs you change the caption, if not you don't
    https://www.fmsinc.com/microsoftacce...args/index.htm

    if you know frmchoosestatus is open then just pull the value as required. eg
    inside your report

    Code:
    on error resume next 'if this code fails then ignore the follwoing line as the form is almost certainly not open
    me.title = 'thevalue from frmchoosestatus is:' & forms!frmchoosestatus!fraStatus
    on error goto 0 'turn off the error 'handler'
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Mar 2013
    Posts
    70

    Thanks, that worked.

    Quote Originally Posted by healdem View Post
    consider setting the openargs property of the openreport macro
    then test the openargs property inside the repot in a suitable event and set the caption accordingly. But be aware that some events fire before you can 'fiddle' with the design. think it has to be AFTER the open report. the advantage oif this approach is that, providing you test if there is a suitable value of openargs you change the caption, if not you don't
    https://www.fmsinc.com/microsoftacce...args/index.htm

    if you know frmchoosestatus is open then just pull the value as required. eg
    inside your report

    Code:
    on error resume next 'if this code fails then ignore the follwoing line as the form is almost certainly not open
    me.title = 'thevalue from frmchoosestatus is:' & forms!frmchoosestatus!fraStatus
    on error goto 0 'turn off the error 'handler'

    OpenArgs in formload worked great. thank you for the help. have a great day. Scott

Posting Permissions

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