Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VB app opening a report (VB 6 Crystal 8.5)

    I'm trying to work out how to pass a dataset to a crystal report and open the report.

    It is returning the error "run-time error -2147192184 (80047288)" Server has not yet been opened.

    CODE:
    Dim objCRXRpt As CRAXDRT.Report
    Dim objCRXApp As CRAXDRT.Application
    ' sqlstr = "select........... left out as it is quite large, but when used i.e. objSQL.fields("fieldname") it works fine.
    objSQL.Open (sqlstr), objConn, adOpenDynamic


    Set objCRXApp = CreateObject("CrystalRuntime.Application")
    rptname = "c:StockEmail.rpt"
    Set objCRXRpt = objCRXApp.OpenReport(rptname)
    objCRXRpt.Database.SetDataSource objSQL

    filename = "C:StockFaxTmp.rtf"

    With objCRXRpt.ExportOptions
    .DiskFileName = filename
    .FormatType = CInt(4)
    .DestinationType = CInt(1)
    .UseReportDateFormat = True
    End With
    With objCRXRpt
    .MorePrintEngineErrorMessages = False
    .EnableParameterPrompting = False
    .DiscardSavedData
    End With
    objCRXRpt.Export (False) 'Disable prompting of export message



    Any help would be much appreciated.

  2. #2
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB app opening a report (VB 6 Crystal 8.5)

    Just guess here, since you don't mention which line is erroring, but in the line:

    objSQL.Open (sqlstr), objConn, adOpenDynamic

    Are you sure objConn is a vilid connection?
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  3. #3
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB app opening a report (VB 6 Crystal 8.5)

    Appologies, my mistake, that was something I put in when trying to work out what was wrong with it.

    It should be:
    objSQL.Open (sqlstr), objConn

    The code is erroring on the following line:
    objCRXRpt.Export (False) 'Disable prompting of export message

    I have found out a bit more info in that it may be something to do with Server Logon and I might have to be using:
    SetLogOnInfo
    Just looking for more info on it now.

    Just had an alternative passed to me, that is to re-create the SQL view and leave the report with its standard dataset. I'll try and find the time to work out the original method though as I'm sure i'll need to pass data to a report at some stage!

  4. #4
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB app opening a report (VB 6 Crystal 8.5)

    Ok, well, not being familiar with Crystal, the only other thing that I can suggest is put a Watch on objCRXRpt and step through the code and see if anything is resetting the object.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  5. #5
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB app opening a report (VB 6 Crystal 8.5)

    I think the actual object is ok as I can still do objsql.fields("fieldname") on it so the recordset is still open as far as the program is concerned, just not Crystal.

    The part I mentioned before involves something like this:

    Dim crDatabase As CRAXDRT.Database
    Dim CrDBTables As CRAXDRT.DatabaseTables
    Dim CrDBTable As CRAXDRT.DatabaseTable

    Set crDatabase = CrSubreport.Database
    Set CrDBTables = crDatabase.Tables
    Set CrDBTable = CrDBTables.Item(1)

    CrDBTable.SetLogOnInfo ServerName, DBName, UID, pwd

    Im just trying to work out how CrDBTables.Item(1) refers to the tables involved.

  6. #6
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB app opening a report (VB 6 Crystal 8.5)

    That may be the case but objsql and objCRXRpt are 2 different objects and objCRXRpt is the one giving you the problems.

    Like I said, I'm just guessing here.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  7. #7
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB app opening a report (VB 6 Crystal 8.5)

    All the help I get is much appreciated - been banging my head against my desk all day with this!
    Thanks Bryan, ill try and find out exactly whats happening with objCRXRpt.

Posting Permissions

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