Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problems with recordseletionformula

Status
Not open for further replies.

smoky2

Programmer
Jan 31, 2005
10
DE
I am new to cr10 using vb6 and cr4.6 in the past
vridy gave me a hint but it does not work. Both reports (filtered and unfiltered) are the same. they differ using cr4.6. Any hint to solve my problem?

My program:
Dim Titel As String, Mldg As String, Stil As String, Antwort As String
Dim crApplication As CRAXDRT.Application
Dim crReport As CRAXDRT.Report

frmBerichte.Show
frmBerichte.AbsBlJListeAbfrage 'sql question is store in access.mdb
Unload frmBerichte

Set crApplication = New CRAXDRT.Application
Set crReport = crApplication.OpenReport(App.Path & "\Berichte10\AbsBlJListe.rpt", 1)

Titel = "Abschreibung nach Bilanzjahren"
Mldg = "Soll nur das Bilanzjahr gedruckt werden?"
Stil = vbYesNo + vbQuestion + vbDefaultButton1
Antwort = MsgBox(Mldg, Stil, Titel) ' Meldung anzeigen.

If Antwort = vbYes Then
crReport.RecordSelectionFormula = "{AbsListe.BlJ} = '" & Bilanzjahr & "' "
End If

CRViewer1.ReportSource = crReport
CRViewer1.ViewReport
 
Is your intention to overwrite the report's record selection formula, or to append to it? There is a difference in the way the OCX control handled this as opposed to the RDC. The OCX appended to the record selection, whereas the RDC will replace it (here's a whitepaper on this).

If you need to append to the existing formula, you can try something like this:

Dim strRSF As String
strRSF = crReport.RecordSelectionFormula
strRSF = strRST & " and " & "{AbsListe.BlJ} = '" & Bilanzjahr & "' "

You might want to step through the code to verify that the strRSF variable actually reads the current record selection formula, as I seem to remember having an issue with that in CR 9.

-dave
 
Thank you again vidru. I had to travel and was not able to read your message earlier.

I’m creating and storing the named sql-statement in an access database.

The crReport is using that named sql-statement.

Sometimes I would like to have only a special part (a selection) of all records called by my named sql-statement.

Using OCX of CR 4.6

CrystalReport1.SelectionFormula = "{named sql-statement.columnname} = '2005' "

The content of the report shown are only records with ‘2005’


Using OCX of CR 10

CrReport.RecordSelectionFormula= "{named sql-statement.columnname} = '2005' "

The report shown is not selected. The report shows all records. Why?????
 
It could be a saved data issue. Try calling the DiscardSavedData method before setting the RecordSelectionFormula:

CrReport.DiscardSavedData
CrReport.RecordSelectionFormula= "{named sql-statement.columnname} = '2005' "

-dave
 
thank you,dave but CrReport.DiscardSavedData before will not help. The report with and without CrReport.RecordSelectionFormula= "{named sql-statement.columnname} = '2005' " are the same.
Any further idea?

 
problem solved!
I used a new frmCrystalReport.frm and wrote the identical programm into it. The filter worked correct.
One not answered question is, why the filter does not work at frmMenue.frm?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top