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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RoLaAusCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.