Results 1 to 4 of 4

Thread: Report Controls

  1. #1
    Lounger
    Join Date
    Jan 2001
    Location
    Swindon, Wiltshire, United Kingdom
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Report Controls

    Does anyone know a good reason why a field in the ControlSource of a report cannot be referred to unless a control bound to the field appears on the report. I'm not sure but I thought that this was possible at some time in the past (version 2 maybe?). The obvious way to get round the problem is to make place the control on the report then make its Visible property 'No'.

    It's always been a slight irritation, particularly if there are a number of fields that might be referred to within the OnFormat action.

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Report Controls

    Well, I've used every version of Access, and it's never worked for me in code. I suspect it has to do with the nature of reports, and the grouping that goes on behind them. Figuring out exactly which instance of a field you were referring to could be a bit hairy. Even when you reference a control rather than a field, it can't be in a lower level of the report.

    You can reference underlying fields in controlsource values as long as you don't have a control with the same name.
    Charlotte

  3. #3
    Lounger
    Join Date
    Jan 2001
    Location
    Swindon, Wiltshire, United Kingdom
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Report Controls

    Thanks Charlotte. With regard to referencing underlying fields, that was a hard earned lesson some time ago until I realised that I'd changed a ControlSource from a field to a calculation and it didn't like it! Renaming the control solved that one but it took a long time to realise it.

    My recollection of whether it worked in version 2 was a bit hazy so I'm not surprised that it didn't work.

    When referencing a field that appears on the report the value returned depends on the current record. If using the OnFormat event of the Details section then there is no ambiquity about the record and so I can see no reason why a reference could not be made to a field for that record in the RecordSource (similar to in a form).

    In the other sections of the report the 'current' record is, as far as I can tell, the first (in a header) or last (in a footer) record in the group and that is how, for example, the Department name would be shown in a Department header - as the value in the Department field for the first record in the group. If that's the case then I still can't see a problem in referencing the field in the ControlSource.

    But, hey, it doesn't work so I guess I'll just keep on adding the controls and setting them to Visible - No.

    Thanks again.

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Report Controls

    You can reference underlying fields in controlsources, you just can't reference them in code.
    Charlotte

Posting Permissions

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