WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Crystal Reports

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Set Crystal Reports Parameters

 Keywords: set Crystal Reports parameters 

A ways back I posted code to run a crystal report, with crystal prompting for report parameters. I finally figured out how to set the parameters in winbatch.

cra = objectopen("CrystalRuntime.Application")

cra.LogOnServer("PDSODBC.DLL","server","db","user","pass")

  ; open the saved report
  crr = cra.OpenReport("H:\COMPANY\CR\QR-NWQ-3.rpt")
    crr.DiscardSavedData()

    ; locate and set the {?xAuth} parameter
    crpardefs = crr.parameterfields
      crpardefs_h = ObjectCollectionOpen(crpardefs)
        while 1 
          crpar = ObjectCollectionNext(crpardefs_h)
            if crpar == 0 then break
            switch 1
              case crpar.name == "{?xAuth}"
                crpar.SetCurrentValue("14")
                break
            endswitch
          ObjectClose(crpar)
        endwhile
      ObjectCollectionClose(crpardefs_h)
    ObjectClose(crpardefs)

    ;Export html
    hfile = "c:\windows\desktop\QR-NWQ-2.htm"
    cre = crr.ExportOptions
      cre.DestinationType = 1 ; diskfile
      cre.FormatType = 24     ; 24=html
      cre.HTMLFileName = hfile
      crr.Export(BOOL:@false)
    objectclose(cre)

  objectclose(crr)
objectclose(cra)

exit

Article ID:   W15610
File Created: 2003:05:13:11:29:12
Last Updated: 2003:05:13:11:29:12