See queries in Crystal Reports

Although you don’t need to upgrade to Visual Basic 5 to get the latest version of Crystal Reports, the version that ships with Visual Basic 5 (and Visual Basic 4) has a great new feature: the ability to see queries. You simply construct a Jet query to do joins instead of using links in Crystal Reports. The old way of getting information from queries was by means of a temporary table.

Crystal Reports still doesn’t let you see parameter queries, but why not write your own ActiveX object to run reports? At TMS, ours takes a collection of parameters—each made up of a parameter object containing the parameter name and value—and writes the results to a temporary table. The report is then run against this table. The alternative is to generate the SQL and save it as a query. Thus, the same Crystal Reports query for totaling account balances could be used with several different reports.

Const PRINT_REPORT As Integer = 1
Dim qd             As QueryDef
Dim sDate          As String

sDate = Format$(InputBox$(""))
Set qd = PubDB.CreateQueryDef("qryReport", _
    "Select Name From Names " & _
    & "Where DateAdded > " & sDate)
DB.QueryDefs.Append qd
rptctl.Action = PRINT_REPORT