x

how to refer the text box reference to embedded code in ssrs 2008

Private Function CalculateFeesDue() As Single

  Dim bffr As String: bffr = Trim(txtStudentFeesPaid.Text)
  Dim bffrlngth As Integer: bffrlngth = Len(bffr)
  Dim p As Integer: p = 1
  Dim FD As Single

  FD = Val(ExtractBuriedNumber(txtFeesDue.Text, 1))
  FD = FD - Val(ExtractBuriedNumber(txtSponsor1Fees.Text, 1))
  FD = FD - Val(ExtractBuriedNumber(txtSponsor2Fees.Text, 1))
  Do While p <= bffrlngth
    FD = FD - Val(ExtractBuriedNumber(bffr, p))
    NextDelimiter bffr, Chr(13), p
  Loop

  CalculateFeesDue = FD

End Function

The above function which was written in VB, the same function i am using in SSRS 2008 and where there is txtFeesDue.Text (which is a VB text box) there i need to reference Textbox from SSRS.

how it is possible?
more ▼

asked Jun 23 '11 at 06:11 AM in Default

Murali gravatar image

Murali
906 87 114 120

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

How and where you are using this function?

From my experience you are not able to refer a TextBox or other report part in the function.

I suggest you to introduce a parameters to the function instead of trying to implement text box references. So remove the TextBox.Text properties from the function and replace this by parameters.

Then in the call of the function you will pass the Expressions which represents particular TextBox values as parameter to that function.
more ▼

answered Jun 23 '11 at 11:09 AM

Pavel Pawlowski gravatar image

Pavel Pawlowski
22.2k 8 11 21

@Pavel Pawlowski It looks like we are on the same page here, but you are just faster :)
Jun 23 '11 at 11:18 AM Oleg
(comments are locked)
10|1200 characters needed characters left

This is one fine example of how cumbersome sometimes it can be to reference the objects outside of the function's scope. What I mean is that if you have such a function written for one app and then you need to implement the same function for another app then it is easy to notice that the good old friend copy-paste does no longer work :(

If you modify the function to accept 4 string parameters (or 1 parameter of the string array type) then it would be a bit better, so instead of referencing the hardcoded text box names and hoping that these will never change, you can just use the values of the parameters instead:

Private Function CalculateFeesDue( _
    ByVal studentFees as string, ByVal feesDue as String, _
    ByVal sponsorFees1 as String, ByVal sponsorFees2 as String) As Single

    Dim bffr As String: bffr = studentFees.Trim()
    Dim bffrlngth As Integer: bffrlngth = bffr.Length
    Dim p As Integer: p = 1
    Dim FD As Single

    FD = Val(ExtractBuriedNumber(feesDue, 1))
    FD = FD - Val(ExtractBuriedNumber(sponsorFees1, 1))
    FD = FD - Val(ExtractBuriedNumber(sponsorFees2, 1))

    Do While p <= bffrlngth
        FD = FD - Val(ExtractBuriedNumber(bffr, p))
        NextDelimiter bffr, Chr(13), p
    Loop

  Return FD

End Function

This way, you can query the Text properties of whatever boxes are available to the calling code and pass them as parameters to this function which is no loger bound to the boxes' names.

Oleg
more ▼

answered Jun 23 '11 at 11:16 AM

Oleg gravatar image

Oleg
15.9k 2 4 24

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x112

asked: Jun 23 '11 at 06:11 AM

Seen: 1572 times

Last Updated: Jun 23 '11 at 10:57 AM