On Crystal Reports and VB 6

aoi
10-27-2004, 12:59 AM
Hi! I'm using the Crystal Reports Pro in VB and I'm wondering how to configure the sql statement so the report will only show one record. I'm using 3 tables from my database. It's like I want to show on the report a resume of a person. From my vb application I want to pass the value to be added to the sql statement in the crystal report.

here is the sql statement in the Crystal Report:

SELECT
RESUME."OBJECTIVE", RESUME."BACKGROUND", RESUME."REFERENCES",
RESUMEENTRY."DURATION", RESUMEENTRY."TITLE", RESUMEENTRY."DESCRIPTION", RESUMEENTRY."TYPE",
USERS."FNAME", USERS."LNAME", USERS."TELNO", USERS."CELNO", USERS."ADDRESS", USERS."EMAIL"
FROM
"SCOTT"."RESUME" RESUME,
"SCOTT"."RESUMEENTRY" RESUMEENTRY,
"SCOTT"."USERS" USERS
WHERE
RESUME."RESUMEID" = RESUMEENTRY."RESUMEID" AND
RESUME."USERSTUDENTID" = USERS."USERID"

From my VB Application, I want to pass the value of USERID and RESUMEID. How cn I add this values to the Sql Statement in the Crystal Report.

Can anybody here help me. Thanks. ~_^

Harkon
10-27-2004, 03:11 AM
Greetings,
try this after editing where nessessary to fit your needs

Dim crxApp As CRAXDRT.Application
Dim crxRpt As CRAXDRT.Report
Dim crxTable As CRAXDRT.DatabaseTable
Dim strString As String

Set rs = New ADODB.Recordset
Set crxApp = New CRAXDRT.Application

'replace this with your selection query
strString = "select ..."

'open the recordset
rs.Open strString, cn, adOpenKeyset, adLockOptimistic, adCmdText

'set our report object <enter your report's name here>
Set crxRpt = crxApp.OpenReport(App.Path & "/myReport.rpt", 1)

For Each crxTable In crxRpt.Database.Tables
'replace server,dbname,username,password with your connection values
crxTable.SetLogOnInfo server, dbname, username, password
Next

'remove any saved data
crxRpt.DiscardSavedData

'bind the new recordset
crxRpt.Database.SetDataSource rs



hope this helps,
let us know
Regards

aoi
10-27-2004, 04:30 AM
Harkon, I have a problem there is an error on this line:

Dim crxApp As CRAXDRT.Application

What does CRAXDRT mean? thanks

Harkon
10-27-2004, 04:45 AM
you should add the proper Crystal Report References to your Project in Visual Studio.
I add all references named "Crystal ... " though I don't know which one(s) you need only. Try them all to be sure of it.

aoi
10-27-2004, 04:53 AM
I'm using the Crystal Report Pro of VB 6. I only have the Crystal Report Control 4.6 on my components. :confused:

Harkon
10-27-2004, 05:02 AM
ouch! that slipped my notice.
i'm not sure if you can do what you want with this version of Crystal :(

aoi
10-27-2004, 05:23 AM
ok. guess i'll have to install higher version of it. thanks for your info. :)

MKoslof
10-29-2004, 12:00 PM
If upgrading is not an option (I suggest doing this :) ), you can pass a .selectionformula or .recordselectionformula to restrict the returned result set. Or, you can use the parameters collection, I believe this is available to you in older versions of CR.

aoi
11-03-2004, 08:33 PM
Hi again. I'm now using Seagates Crystal Report 7.0 and I'm just wondering how can I show my report using VB. Its a pre-defined report and I don't need to pass n sql statement on it. Can anybody here help me? Thanks.

By the way Harkon I still can't figure out the code you gave me. My problem is still on what CRAXDRT means. :confused:

MKoslof
11-06-2004, 09:01 AM
Add a reference to the Crystal Reports Active X Design and Runtime libraries in your VB project...now you can use the CRAXDRT objects.

Use the CRViewer control to view your report, use the .printout method to simply send it to the printer.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum