Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Posts
    47

    Unanswered: ASP not passing value back from FUNCTION

    Hi All,
    I have the following code in the body of my ASP page:
    **snippet**
    Dim sreport
    if right(strPhysicalFolder,1) <> "\" then strPhysicalFolder = strPhysicalFolder & "\"
    sname = strPhysicalFolder & GetTemplateName(sreport)
    redim arrDisplay(icols, irows)
    AddArrayToExcel arrData, datetype, sname, icols, irows, sheading
    else
    rst.Close
    NoDataMessage access
    end if

    Function GetTemplateName(sreport)
    'returns the name of the template depending on the report type
    Dim sname
    select case sreport
    case "clientrpt"
    sname = "client.xlt"
    case "toprpt"
    sname = "top.xlt"
    case "contrpt"
    sname = "cont.xlt"
    case else
    sname = "comp.xlt"
    end select
    GetTemplateName = sname
    end function

    However it always executes the ELSE part and gets the comp.xlt template even when I have chosen one of the other reports.

  2. #2
    Join Date
    Apr 2004
    Posts
    50
    You haven't specified the value of sreport, so every time you call your function the sreport parameter is empty, hence you get the else case.

  3. #3
    Join Date
    Apr 2004
    Posts
    47

    The difference is I'm now not calling a class object

    Before, I used to call it like this:

    The report string is passed into this ASP page.
    reporttype = Request.QueryString("reporttype")

    SQL = GenerateSQL(reporttype, username, userid, variable, sSQL, fromdate, todate, stype, yearno)

    SQL = GenerateSQL(reporttype, username, userid, variable, sSQL, fromdate, todate, stype, yearno)

    if SQL <> "" then getDisplayArray SQL, reporttype, irows, icols, arrData, arrDisplay

    sub getDisplayArray(sSQL, sreport, irows, icols, arrData, arrDisplay)
    'uses the Class csDBController to build the array into the correct format
    'Build the display array from the SQL string passed
    set dbcontroller = new csDBController
    with dbcontroller
    .DBConnection = strWSA
    .MakeConnection
    .SQLString = sSQL

    irows = .CreateArray(arrData, icols)
    'Response.Write "back in getdisplayarray"
    if irows > 0 then
    if right(strPhysicalFolder,1) <> "\" then strPhysicalFolder = strPhysicalFolder & "\"
    sname = strPhysicalFolder & .GetTemplateName(sreport)
    redim arrDisplay(icols, irows)
    end if
    .CloseConnection

    end with
    set dbcontroller = nothing
    end sub

    public function GetTemplateName(sreport)
    'returns the name of the template depending on the report type
    Dim sname
    select case sreport
    case "clientrpt"
    sname = "client.xlt"
    case "toprpt"
    sname = "top.xlt"
    case "contrpt"
    sname = "cont.xlt"
    case else 'comparison
    sname = "comp.xlt"
    end select
    GetTemplateName = sname
    end function


    This worked. The only difference is that I am using a class object .GetTemplate name.
    I had to change the inherited code and it was suggested to have this in the SAME asp page.
    Now I have the GetTemplate name in the same ASP Page, it does not call the correct template, defaults to the CASE Else.

    Thank you!!

Posting Permissions

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