PDA

Click to See Complete Forum and Search --> : Selecting only certain records?


drag0n_45
Mar 21st, 2008, 03:37 PM
Hello all,
I have a crystal report going to a database for my report currently. In that database I hold all the information needed to previous reports as well as the report I am trying to print, which will be the most recent report 9/10 times. (This will be the report with the highest primary key). I need to know how to specify to crystal to only look at records from the database which have the primary key i speciify (if i could modify the SQL query of the report that would be awesome). I know how to call up the report from vb, just not manipulate it...

Thanks in advance,

rasinc
Mar 22nd, 2008, 07:42 PM
Haven't tried it but does

Maximum ({fieldname})

work?

VBFnewcomer
Mar 23rd, 2008, 11:54 PM
Not sure what you want but from I need to know how to specify to crystal to only look at records from the database which have the primary key i speciify (if i could modify the SQL query of the report that would be awesome). it appears you may want to use parameter fields. More if I had understood you correctly...

drag0n_45
Mar 24th, 2008, 07:45 AM
Well. Let me try to explain more clearly. I have a knack for not explaining well. I have a database that holds all the previous reports as well as the latest report. This is the database that Crystal uses to retrieve its report. When I call up the report in VB, I want to tell Crystal only to look at one entry in the database (instead of all of them) to display the report. The primary key of that entry will link up to the primary key of another table, which I have already specified in Crystal. The program I am writing is a Bill of Lading program that displays all shipment information for a given shipment, including details regarding each packages. It also saves all previous shipment records and prints the latest record when it is generated. It gives the option to print previous records, hence the need to only choose one record from the database (which will include multiple packages).

If I were doing this in an SQL query, that statement might look like this: SELECT Shipments.*, Packages.* FROM Shipments INNER JOIN Packages ON Shipments.PriKey = Packages.Prikey WHERE Shipments.ShipmentNumber="08-001"

The problem is the shipment number must be dynamic and passed as a parameter to Crystal. I have no idea how to set this up or implement this in code, as I am new to crystal.

drag0n_45
Mar 24th, 2008, 09:47 AM
I've figured out how to do this using the select expert in Crystal itself, but how do you code a select expert definition in VB?

VBFnewcomer
Mar 24th, 2008, 11:52 PM
I've figured out how to do this using the select expert in Crystal itself, but how do you code a select expert definition in VB?
That's a good beginning :afrog:
Now if you have seen the select expert (Show Formula.. button) it is just a SQLquery, so you could simply pass the SQL to the report object Report.SqlQueryString = SQLquery

The coding could be slightly diff in diff version of CR. what's yours?