Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Report field (XP)

    Hi, its been a while for me to post in the lounge, how is everyone [img]/forums/images/smilies/wink.gif[/img]

    I have a report which has an unbound text field in it, which i want to set to a string before the preview, whats the easiest way of doing this? I was using the 'OpenArgs' but then I was annoyingly prompted to save my changes each time the preview was closed.

    at the mo i have this code off a button on my form

    ' open report with current recordset as record source
    ' get Current group Name, assign to string picked up by report
    strReportName = Me.cmbGroup.Column(1, Me.cmbGroup.ListIndex)
    'set report's recordsource to currently viewed one
    DoCmd.OpenReport "PeopleTrained", acViewDesign
    Reports!peopletrained.RecordSource = Me.People_Trained_Subform.Form.RecordSource
    'save changes
    DoCmd.Close acReport, "PeopleTrained", acSaveYes
    'open preview
    DoCmd.OpenReport "PeopleTrained", acViewPreview

    and the field txtTitle in my Report is simply

    =Forms!{Training Types}.strReportName

    where strReportName is declared Public in the Forms Code. ( I use square brackets in my code, but they do funny things in the lounge [img]/forums/images/smilies/wink.gif[/img])

    I know this MUST be simple really!
    Thanks,

    pmatz

  2. #2
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Report field (XP)

    Thanks Francois, thats a new approach for me, I haven't ever done much with Reports before now...

    I just change the onOpen event code to

    Me.RecordSource = Forms!{Training Types}.People_Trained_Subform.Form.RecordSource

    and it works sweeet

    [img]/forums/images/smilies/smile.gif[/img] Cheers, Happy New year!
    Thanks,

    pmatz

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Report field (XP)

    Delete the following code in the form.
    'set report's recordsource to currently viewed one
    DoCmd.OpenReport "PeopleTrained", acViewDesign
    Reports!peopletrained.RecordSource = Me.People_Trained_Subform.Form.RecordSource
    'save changes
    DoCmd.Close acReport, "PeopleTrained", acSaveYes

    In the On Open event of the report enter :
    Me.RecordSource = Forms.People_Trained_Subform.Form.RecordSource

    In the On Format event of the section of the report that contain txtTitle enter the code :
    Me.txtTitle = Forms!<!t>[Training Types]<!/t>.strReportName
    Francois

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Report field (XP)

    If you want to have <!t>[Training Types]<!/t> you can use <!t>[t]<!/t>Training Types<!t>[/t]<!/t> when you type the message.
    I don't know why Training Types disappear when you use the normal square brackets.
    Francois

Posting Permissions

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