Results 1 to 7 of 7

Thread: [RESOLVED]Second call to CR fail

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,414

    Resolved [RESOLVED]Second call to CR fail

    Hi to all:

    I have this code for a report in VB6:

    Code:
    Set Report = New CRAXDDRT.Application
    Set Rpt = Report.OpenReport(App.Path & "\Ficha_Individual.rpt")
    
    If (Rpt.HasSavedData) Then Rpt.DiscardSavedData
    
    'set the section object to the Page Header section of the report.
    Set oSection = Rpt.Sections("PH")
    
    For i = 1 To oSection.ReportObjects.Count 
      If oSection.ReportObjects(i).Kind = CRAXDDRT.crOleObject Then ' if it is a CrOleObject then
          Set pic1 = oSection.ReportObjects(i) 
      End If
     Next i
     
    Rpt.ParameterFields.GetItemByName("anilha").AddCurrentValue (FrmFicha_Aves_Mortas.Text1(1))
    
    setviewersize
    
    CRViewer1.ReportSource = Rpt
    
    CRViewer1.ViewReport
    When I call the report everything work well...When I make a second call a got this error in this line:

    Error:"Object doens't support this action"

    Code:
    'set the section object to the Page Header section of the report.
    Set oSection = Rpt.Sections("PH")
    I need to refresh the report or do something?

    Thanks
    Last edited by sacramento; Aug 11th, 2008 at 11:21 PM.

  2. #2
    Hyperactive Member
    Join Date
    Jul 2007
    Posts
    479

    Re: Second call to CR fail

    I would test to see if the current section is already PH or trying the .reset command before you set the section.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,414

    Re: Second call to CR fail

    You mean this?

    Code:
    Rpt.Sections.Reset
    but .reset command don't exist in this method

  4. #4
    Hyperactive Member
    Join Date
    Jul 2007
    Posts
    479

    Re: Second call to CR fail

    Sorry, I use the ocx more. I am just starting to use the rdc. Try this:

    Code:
    Report = Nothing
    Set Report = New CRAXDDRT.Application
    Or

    Code:
    If oSection <> Rpt.Sections("PH") then
         Set oSection = Rpt.Sections("PH")
    end if
    Hope this helps

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,414

    Re: Second call to CR fail

    Hi:

    No in fact the error remain...with the first code the correct syntax is:

    Code:
    Set Rpt = Nothing
    but nothing happens...

    the second code generate a error...

  6. #6
    Hyperactive Member
    Join Date
    Jul 2007
    Posts
    479

    Re: Second call to CR fail

    From the document scr8-ocxtordc.pdf:

    RDC:
    To Reset the report, set the Report object to “Nothing”, then open the report again and set the new properties. See
    the OCX property ReportFileName for the RDC methods for opening reports.
    ‘Set the Report object to Nothing
    Code:
    Report = Nothing

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,414

    Re: Second call to CR fail

    Hi:

    The problem is resolved...
    I had put this in the end of the code:

    Code:
    Set oSection = Nothing

    Thanks for your help

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