Re: Big Time Help Needed...
First of all, you are using DoEvents waaaaay too many times. DoEvents is one of the slowest executing functions in VB, and should be used once in your case, or if used in an infinite loop, once per frame. Also, in VBForums, try putting your code in [vbcode] [/vbcode] tags so it looks more readable like so:
VB Code:
Public Sub Export2XLS()
Dim sDestinationPath As String
sDestinationPath = destination path
'Open the report
Set CrystalReport = CrystalApp.OpenReport(rptpath)
With CrystalReport.Database
.LogOnServer "PDSODBC.DLL", "SCOPACESQLP1", "crystal", "VBapp_2006", "PACE_VBpw1"
End With
Set CrystalExportOptions = CrystalReport.ExportOptions
DoEvents
CrystalExportOptions.ExcelMaintainColumnAlignment = True
DoEvents
CrystalExportOptions.ExcelConstantColumnWidth = 500
DoEvents
CrystalExportOptions.FormatType = crEFTExcel80
DoEvents
CrystalExportOptions.ExcelPageBreaks = False
DoEvents
CrystalExportOptions.DestinationType = crEDTDiskFile
DoEvents
CrystalExportOptions.DiskFileName = sDestinationPath
'Export the report without prompting the user
DoEvents
CrystalReport.Export False
End Sub
Re: Big Time Help Needed...
Also add some error handling code to identify the exact issue.
Moved
Re: Big Time Help Needed...
I added an error.description and it read: 'Failed to open the connection'
Which I know is the problem, but when I open the crystal report and type in the exact same info that I am passing through via VB, the report connects, opens, and looks beautiful.
Some I'm wondering if there is something I am missing in the connection string in VB (Which I've posted) or is there some trick in Crystal that I might not know about that needs to be done?
Thanks again. And sorry about the ugly VB code posted in the Forum. I just did a cut and paste and didn't realize it looked so ugly.
Re: Big Time Help Needed...
Looks like your using an ODBCX connection on your system but do you also have it created on the other system?
Re: Big Time Help Needed...
Could you explain what you mean by that?
I've created VB apps before that can export files to xls format using the crystal, but this is the first time I've had to pass a connection string to the crystal and I'm afraid I'm starting to get totally lost here.
Could you please explain it to me like I was 5 years old?
Thanks.
Re: Big Time Help Needed...
Ok, in CR when you were creating your report, how did you create your reports datasource?
Re: Big Time Help Needed...
ODBC - Enter Connection String (driver=sql server;server=servername;database=databasename
Then, next screen it asks for user id and password. As well as if trusted connection, which I reply no.
which part am I doing wrong?
Re: Big Time Help Needed...
Then you need to create that same ODBC connection on the other system(s). Its part of the pain of using ODBC.