Click to See Complete Forum and Search --> : Please Help! Very Urgent


Azhar S
May 16th, 2001, 01:23 AM
tell me whether
1. can we use more than one SelectionFormula? If yes How?
2. How to avoid generating report if no value is entered in the text box. (Optional)

I'm using Crystal Reports 6.0 and VB as front end.
I used 8 tables in report with Id as the primary key and relationships are established.

The problem is while displaying a report by taking Id from one table and when the particular ID doen't exist in any one of the table still it is displaying all the field names with blank field values which should not happen.
Whereas if the entry of particular ID exists in the tables it is working fine. i.e. suppressing the section whose field values are blank

I used Format Section to suppress sections with blank field values.
RecordSelectionFormula is from the master table.

If the ID entered doesn't exist in any one of the table then the entire field names related to that table should not be displayed.

How to solve this problem?

Thanks in Advance

Cimperiali
May 16th, 2001, 03:33 AM
from msdn:
SMS: Crystal Reports Selection Formula Reappears After Being Deleted
ID: Q256074


--------------------------------------------------------------------------------
The information in this article applies to:

Microsoft Systems Management Server version 2.0

--------------------------------------------------------------------------------


SYMPTOMS
After you remove the selection formula for a report and reschedule it to run, the report may continue to run with the removed selection formula.



CAUSE
The selection formula is not removed from the report even though the Selection Formula box has been cleared. Replacing the formula with a new formula works.



WORKAROUND
Make a new report object and run the report with the new object:

Right-click the report, point to All Tasks, and then click Schedule Report.


Under Report Properties, you see Report File. Write down the file path in this box.


Click Cancel.


Right-click the report folder in which you want to create the new report object, point to New, and then click Report Object.


Under Report Properties, add the path you wrote down in the Report File box. Provide a title for the new object, and a description if appropriate.

another way to solve it is to use parameter fields to pass value to your omit formulas, and to check for records existence before invoking the printing of report:

Private Sub Command1_Click()
'A simply report with one parameter field
'called SelectMe and another called SelectTwo placed in head of report and used
'in a omit formula for a section.
'Matter is to pass two parameter values to the rpt file
'through Ocx - or: to make parameter fields to be filled
'via code form VB.
Dim yourparametervalue
Dim yourparametervalueTwo
'cr1 is CrystalReport control, added on form
'Nb: I am using CrystalReport 8.0
Cr1.Reset
Cr1.ReportFileName = "D:\Report1.rpt"
Cr1.ReportSource = 0
Cr1.DiscardSavedData = True
'check for records
'ie: sql= "select yourfiledId from yourtable where yourfiledId = yourparametervalue
'execute it. If at least one record, then:
'so: if...
yourparametervalue = "0"
yourparametervalueTwo = "1"
Cr1.ParameterFields(0) = "SelectMe;" & yourparametervalue & ";false" 'parameter field name={?SelectMe}
Cr1.ParameterFields(1) = "SelectTwo;" & yourparametervalueTwo & ";false"
Cr1.Action = 1 'make it print
'or:
'myvar = Cr1.PrintReport
'MsgBox myvar
'else 'you have no records
'msgbox "No record to print"
'end if

End Sub

Hope this may help
Cesare Imperiali

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.

mancho
May 16th, 2001, 05:37 AM
Maybe you can help me
I have this portion of code

Private Sub Command1_Click()
CrystalReport1.ReportFileName = "D:\Project\test.rpt"
CrystalReport1.ReportSource = crptReport
CrystalReport1.SelectionFormula = "{Personnels.Prénom}>'Tania'"
CrystalReport1.Destination = 0
CrystalReport1.Action = 1
End Sub

and when I try I have a message error "Runtime error 20536. Unable to connect....."
but if I delete the line

CrystalReport1.SelectionFormula = "{Personnels.Prénom}>'Tania'"

I have the report without problems

Azhar S
May 16th, 2001, 07:12 AM
I'm using 8 tables in the report. I'm taking Id value from a text box on form which is selected from one table and the corresponding values of that particular Id from all other tables should be displayed in the report.
The problem is I wanted to suppress those fields of all the tables whose filed values are blank. If the corresponding Id doesn't exist in a particular table it should not display the field names as well of that table.

For that I inserted each field in each section and suppressing section whose field value is blank using format section-edit formula.
when the Id entered exists in the tables it is working fine by suppressing blank fields. But when the corresponding Id doen't exist in a particular table it is displaying just all the field names of that table. Which is unnecessarily increasing no. of pages.

Can u just help me out in solving my problem which is very urgent.

Give me the alternative ways to solve this problem. The 'field Names' of that particular table in which the corresponding Id doesn't exist should not be displayed.

Note: I'm using Crystal Reports 6.0 , Access Database and VB as frontend.

Thanks in Advance.

Cimperiali
May 16th, 2001, 07:16 AM
"Unable to connect" means you do not reach database.
Matter is not in sintax: I checked, it works (at least with crystalReport 8.0)
Check for database position in your prt file (look in Database\set position menu from crystal report).

Next time, post your question as new one, and not inside someone else question (you may have quicker answers)
CrystalReport1.ReportFileName = "D:\report1.rpt"
CrystalReport1.ReportSource = crptReport

CrystalReport1.DiscardSavedData = True 'this discard the data saved in report

CrystalReport1.SelectionFormula = "{Tab01.aaa}>'Tania'"
CrystalReport1.Destination = 0
CrystalReport1.Action = 1

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.

Cimperiali
May 16th, 2001, 07:40 AM
"For that I inserted each field in each section and suppressing section whose field value is blank using format section-edit formula."
Ok. But you should also suppress sections when you find non-exisiting ID
ie:
in the omit formula of a section:
dim retVar as boolean
retVar = false 'set initial value
if {tab01.idField}<>{Tab02.idField} then 'id not found in second table
retVar = true
else
'suppress blanks
if trim({Tab02.filedb}) = "" then
retVar = true
end if
end if
formula = retVar

Hope this help

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.