Selection Criteria from VB6 to Crystal Reports4.6

I'm using VB6 and an Access database for a system I'm developing.  I use  Crystal Reports 4.6 for reporting.

When I use Report.SelectionFormula, it only utilizes one of several selection formulas that I want to use for the report.

How can I pass more than one selection criteria (entered by the user during runtime) to the report?

Pls. cite examples for clarity as I am relatively new to VB6 and Crystal Reports.

Thanks in advance.

Babette
babetteAsked:
Who is Participating?
 
RoLaAusConnect With a Mentor Commented:
I'm not entirely familiar with the newest version (I use VB6 for programs, but my reporting is usually done through Access, if that is where the info is stored).

However, I do remember an instance where I had information in Btrieve instead of Access.  Therefore, I had to use VB and Crystal Reports.

What I ended up doing is filling some criteria information on the form, and based on the users input, I constructed a criteria string in code.

something like (you may have to adjust for proper syntax)

** NOTE the checkboxes are my way of not having to check for null or blank values - the user will turn on the check box in order to fill in the criteria they want

---------------------
dim strCriteria as string


if me.checkbox1 = true then
  strCriteria = me.fieldvalue1
end if

if me.checkbox2 then
  strCriteria = strCriteria & me.fieldvalue2
end if

** NOTE when you use the strCriteria = strCriteria - if the string is blank, it does not matter, and you may need to change it to strCriteria = strCriteria & ", " me.fieldValueX - in order to seperate the values

then just

Report.SelectionFormula = strCriteria
0
 
babetteAuthor Commented:
This is precisely what I do.  I set a SelectionFormula for each data element required using parameters entered by the user during runtime.  My problem is that only one of the several selection criteria is used in the report.

For example, if I set a SelectionFormula for employee type and another for collection date, only the criteria for employee type is  used and the report includes all the rows meeting the employee type criteria even if the collection date is outside of the collection date range specified in the selection formula.  
0
 
babetteAuthor Commented:
This is precisely what I do.  I set a SelectionFormula for each data element required using parameters entered by the user during runtime.  My problem is that only one of the several selection criteria is used in the report.

For example, if I set a SelectionFormula for employee type and another for collection date, only the criteria for employee type is  used and the report includes all the rows meeting the employee type criteria even if the collection date is outside of the collection date range specified in the selection formula.  
0
 
babetteAuthor Commented:
Sorry, I didn't get your answer the first time, but I finally understood after reading it a second time and I get your drift.

I tried it separating the criteria with a ",", but it didn't work, so I tried " and " and it worked beautifully.

I may be able to finally finish this project in time for the holidays.
Thanks and Merry Christmas!
0
All Courses

From novice to tech pro — start learning today.