Results 1 to 7 of 7

Thread: Passing parameter from VB to CR

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2006
    Posts
    6

    Passing parameter from VB to CR

    Below is my code
    My problem is that give me an error about getitembyname saying that "method or data member not found"

    any ideas???

    Code:
    Dim strsql As String
    Set rsconn = New ADODB.Recordset
    OpenDB
        strsql = "SELECT * FROM " & _
        "MASTER_MO WHERE MASTER_MO.SHIP_DATE=#" & frmShipping.cmbShipDate.Text & "# " & _
        "AND MASTER_MO.PO='" & frmShipping.txtPoNo.Text & "'"
        Debug.Print strsql
        rsconn.Open strsql, con, adOpenDynamic, adLockOptimistic, adCmdText
    
        Set CrAppl = New CRAXDRT.Application
        Set CrRep = CrAppl.OpenReport(App.Path & "\RptShipping1.rpt")
        CrRep.FormulaFields.GetItemByName("Container").Text = "'" & Trim(frmShipping.txtContainer.Text) & "'"
        CrRep.DiscardSavedData
        CrRep.Database.Tables(1).SetDataSource rsconn, 3
        CRViewer1.ReportSource = CrRep
        CRViewer1.EnableSearchExpertButton = True
        CRViewer1.DisplayGroupTree = False
        CRViewer1.EnableCloseButton = True
        CRViewer1.EnableZoomControl = True
        CRViewer1.DisplayToolbar = True
        
        CRViewer1.ViewReport
        Do While CRViewer1.IsBusy
            DoEvents
        Loop
         
        CRViewer1.Zoom 94
    Set rsconn = Nothing
    CloseDB

  2. #2
    Hyperactive Member binilmb's Avatar
    Join Date
    Nov 2005
    Location
    Kochi
    Posts
    472

    Re: Passing parameter from VB to CR

    if u are getting error in the following place

    CrRep.FormulaFields.GetItemByName("Container").Text = "'" & Trim(frmShipping.txtContainer.Text) & "'"

    it may be the problem with the object Container. it may not have the porperty "Text".
    ßįňįl

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2006
    Posts
    6

    Re: Passing parameter from VB to CR

    Quote Originally Posted by binilmb
    if u are getting error in the following place

    CrRep.FormulaFields.GetItemByName("Container").Text = "'" & Trim(frmShipping.txtContainer.Text) & "'"

    it may be the problem with the object Container. it may not have the porperty "Text".
    I have remove the text property but it still gave the same error and highlight in GetItemByName.

    Is it needed to activate some reference or else???

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Passing parameter from VB to CR

    Moved to reporting section

  5. #5
    Lively Member
    Join Date
    Mar 2006
    Posts
    94

    Re: Passing parameter from VB to CR

    Quote Originally Posted by joseph.goh
    I have remove the text property but it still gave the same error and highlight in GetItemByName.

    Is it needed to activate some reference or else???
    Is the parameter in CR a string? If it isn't, make it a string.
    Is the parameter named spelled correctly including case?
    Try this:

    .GetItemByName("Container").AddCurrentValue Trim(frmShipping.txtContainer.Text)
    Energy can be neither created not destroyed. It can only be wasted.

    Red Green

  6. #6

    Thread Starter
    New Member
    Join Date
    Mar 2006
    Posts
    6

    Re: Passing parameter from VB to CR

    Quote Originally Posted by King_George
    Is the parameter in CR a string? If it isn't, make it a string.
    Is the parameter named spelled correctly including case?
    Try this:

    .GetItemByName("Container").AddCurrentValue Trim(frmShipping.txtContainer.Text)
    The value is string and the parameter name is correct

    i have change to what u have suggest but when i try to run, it still gave me the error "method or data member not found" and GetItemByName is highlighted

    I think vb cannot get that method, because after i type formulafields. it just prompt out add, count, delete but there is nothing about GetItemByName.

    Any ideas ??

  7. #7
    Lively Member
    Join Date
    Mar 2006
    Posts
    94

    Re: Passing parameter from VB to CR

    Quote Originally Posted by joseph.goh
    The value is string and the parameter name is correct

    i have change to what u have suggest but when i try to run, it still gave me the error "method or data member not found" and GetItemByName is highlighted

    I think vb cannot get that method, because after i type formulafields. it just prompt out add, count, delete but there is nothing about GetItemByName.

    Any ideas ??
    Sorry I misread the post. You cannot assign formula field values from VB. You can however assign values to parameter fields.
    Report.ParameterFields.GetItemByName("parameter_name").AddCurrentValue value_to_add

    In your report, just use that parameter in the formula assuming that this is what you want the value for..
    Energy can be neither created not destroyed. It can only be wasted.

    Red Green

Posting Permissions

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



Click Here to Expand Forum to Full Width