Can I get a value from a parm's dataset that isn't the label or value field

  • Imagine I have a parameter on a report whose available values are based on a dataset.

    The dataset has three fields : FieldA, FieldB, FieldC.

    FieldA is the value field for the parameter

    FieldB is the label field for the parameter

    When a user runs the report I want to be able to display the values in all three fields for the selected parameter row in textboxes on the form.

    For fieldA I use @Company.Value

    For FieldB I use @Company.Label

    Is there a way of getting FieldC?

  • I don't think you can populate a third field, but you can use a second parameter that will take the value for FieldC and use that one.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • I don't think that's what I'm after but I might be miss-understanding you.

    To be clear, when the user picks e.g. row 8 in the drop down box, I want to get at the value in FieldC for row 8. I can't see how adding an extra parameter would help with that because I can't see how I'd "link" it back to the orginal parameter to identify which row the user selected. Am I missing a trick there?

    I guess at the end of the day I could just raise an extra query to retrieve the apropriate FieldC from the database but it just seems wasteful to generate an extra round trip to the server for a value I could have picked up when populating the parm in the first place.

  • Ah yes, I misread the question. I thought the parameter was used internally, so using a second parameter is an option (if you use the query to populate default values).

    Sorry for the confusion.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • I just had another thought. It's a fudge but it'll work. I've simply ammended the query for the main report dataset to return this field for the chosen parm. It'll returnb the same value in every single row so I can simply use First(FieldC) for the text box.

    It is a fudge though so I'll leave this open. If anyone's got a better way I'd still like to hear it.

    edit>

    Sorry for the confusion.

    No worries. I'm always grateful for any response.

  • FunkyDexter (7/11/2012)


    I don't think that's what I'm after but I might be miss-understanding you.

    To be clear, when the user picks e.g. row 8 in the drop down box, I want to get at the value in FieldC for row 8. I can't see how adding an extra parameter would help with that because I can't see how I'd "link" it back to the orginal parameter to identify which row the user selected. Am I missing a trick there?

    I guess at the end of the day I could just raise an extra query to retrieve the apropriate FieldC from the database but it just seems wasteful to generate an extra round trip to the server for a value I could have picked up when populating the parm in the first place.

    It depends on programming tool.

    In Delphi, a DBLookupCombobox control can display dataset values in dropdown, so on close-up you just ask for any other column value for selected row from dataset, no additional queries required. IIRC, there is something similar ready ti use in VB. If you want to display values of one column, you can get this behavior with standard combobox.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply