|
-
Jan 4th, 2004, 01:10 AM
#1
Thread Starter
Junior Member
how to pass parameters to a report
hi!
im newbi here..
i want to know how to pass parametersfrom a from on vb to a report.. if the user enters a string to search for i want to show a report correponding only to that sting.. how i do it__
im using vb 6.0 and crystal reports 8.0
thx
Can you live with yourself
when you think of what
you left behind?
-
Jan 6th, 2004, 06:28 PM
#2
In Crystal, add a Parameter to your report (Insert -> Field Object -> Parameter Fields)
Then modify the Record Selection formula so that the database field must be equal to the parameter field. For example,
{Authors.LastName} = {?AuthorName}
Crystal will then use this information to create a SQL statement to the database, ie
Select * From Authors Where LastName = 'King'
Then in VB, there are two methods to prompt the user. Let Crystal handle everything or do it yourself. By default, Crystal will automatically prompt the user for the paramter values.
How do you currently show the report in VB? Let me know if you want information on handling the parameters your self.
-
Jan 7th, 2004, 06:26 PM
#3
Thread Starter
Junior Member
thanx..
i want to set that formula from my vb aplication, i added a crystal report control and someone told me that i can use the formulas property to send the formula to the reporte already done, then crystal will use that record formula..
but id ont know how to set the formulas property... vb just sends me syntaxis errors..
i have these lines and i set some other parameters of the report in other form, like the reportName
me.CrystalReport1.Formulas="{asistencias.id_alumno}='"&me.DBLAlumnos.BoundText&"' "
Me.CrystalReport1.WindowTitle = Me.txtWindowTitle Me.CrystalReport1.DataFiles(0) = Me.txtReportDBName Me.CrystalReport1.ReportFileName = Me.txtReportName Me.CrystalReport1.CopiesToPrinter = Me.txtCopias
i have a DBList control which shows the students name, so if i select an item it should send the ID (alumno_id) to the formula, to get just the report of that student..
thx for all..
Can you live with yourself
when you think of what
you left behind?
-
Jan 7th, 2004, 08:41 PM
#4
You need to set the selection formula
VB Code:
me.CrystalReport1.SelectionFormula = "{asistencias.id_alumno}='"& me.DBLAlumnos.BoundText & "'"
-
Jan 8th, 2004, 06:24 PM
#5
Thread Starter
Junior Member
thanx..
i just tried the code, and it stopped sending syntaxis errors, but now when i run the application it sends an error:
20515: Error in file asistencias.rpt
Error in Formula <recod_selection>
The remaining text does not appear part of the formula
...................
if i run this formula in the crystal report it does work but not from my application, what can be happening??
Can you live with yourself
when you think of what
you left behind?
-
Jan 8th, 2004, 06:40 PM
#6
Thread Starter
Junior Member
i found the reason...
i should use another property, this is the code...
Me.CrystalReport1.ReplaceSelectionFormula ("{asistencias.id_alumno}='" & Me.DBLAlumnos.BoundText & "'")
thanx to all..
Can you live with yourself
when you think of what
you left behind?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|