Click to See Complete Forum and Search --> : crystal/ parameters


maggie gallotti
May 10th, 2001, 10:58 AM
I am new to crystal.Im using version 4. I am trying to pass a parameter to the report and it doesn't seem to even see it. I am connecting to my dbase(access) via odbc.
Here's part of my vb code:
CrystalReport1.SQLQuery = "select * from contact where contact_type = '" & run_type & "' "
Should I just be setting up the query in crystal? If so, what's the format because nothing I try seems to work.

Cimperiali
May 10th, 2001, 11:24 AM
I use another version of Crystal, so maybe not all of this may apply to you. However, you should be able to set from vb only the where clause of an Sql, not the whole:
Private Sub Command1_Click()

Dim sql As String

Cr1.Reset
Cr1.ReportFileName = "D:\Condivisa\report\Report04.rpt"
Cr1.ReportSource = 0
Cr1.DiscardSavedData = True
'the where clause

'this, if you do not have a selection formula in your report
sql = "{persona.Cognome}='Imperiali'"
Cr1.SelectionFormula = sql

'replace previous with:
'sql = "{persona.Cognome}='Imperiali'"
'Cr1.ReplaceSelectionFormula sql
'if you have already one in rpt file

Cr1.Action = 1
'or:
'myvar = Cr1.PrintReport
'MsgBox myvar
End Sub

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.

maggie gallotti
May 10th, 2001, 01:15 PM
I tried and it still does not work. I get a message "20599". thanks