• Report Controls

    Author
    Topic
    #353050

    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.

    Viewing 0 reply threads
    Author
    Replies
    • #515437

      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.

      • #515642

        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.

        • #515776

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

    Viewing 0 reply threads
    Reply To: Report Controls

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: