?
Solved

Regex in Crystal Reports?

Posted on 2009-05-05
9
Medium Priority
?
619 Views
Last Modified: 2012-05-06
I've read that you cannot use regex in crystal reports, so I'm hoping that any of you can help me with a problem I have.

I have a crystal report on a web page, it get one parameter from the page.(see Code 1)
Where ddlProject is a dropdownlist containing project names.

When used in the selection expert on the report(see Code 2). So that only profiles (e.g. documents) that has the selected project_id will be shown in the report.
Here is where my problem lies.

I have a project with id: 115-20001
Which will display following profiles(see Profiles.jpg)

What I want to do is only display profiles with Project_ID + - + Letter A to Z + -. E.g. 115-20001-F-RD-206-01
So that in the report only will show 115-20001-F-RD-206-01 and 115-20001-A-LA-103-01.

How can I do this?

Thanks in advance:)
Regards
Marius
//Code 1 Default.aspx.cs
ParameterField projectNameParam;
projectNameParam = projectReport.ParameterFields["PROJECT_ID"];
projectNameParam.CurrentValues.AddValue(ddlProject.SelectedItem.Text.ToString());
 
//Code 2 Select Expert formula on report
 {PROFILE.C_PROJECT} = {?PROJECT_ID}

Open in new window

Profiles.JPG
0
Comment
Question by:Contestoas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 24304276
In the data can the letter be other characters?

You can do something like

 {PROFILE.C_PROJECT} STARTSWITH  {?PROJECT_ID} & '-?-'

The ? will match any 1  character.  
If it can be something other than a letter then something will have to be added.
It will work for the sample data.

mlmcc
 
0
 

Author Comment

by:Contestoas
ID: 24304333
Hi

It can only be one letter, between A and Z

Regards
Marius
0
 

Author Comment

by:Contestoas
ID: 24304479
I cant get it to work, it compiles fine, but no data is shown. Maybe it checks for ? instead of characters?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:Contestoas
ID: 24304493
If I insert A instead of ? it will show only the 115-20001-A-LA-103-01 value.
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 total points
ID: 24304713
Try
{PROFILE.C_PROJECT} LIKE  {?PROJECT_ID} & '-?-*'

mlmcc
0
 

Author Comment

by:Contestoas
ID: 24311524
Nope, still doesnt work.

Marius
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 24311613
Worked for me.

Where are you putting the formula?

mlmcc
0
 

Author Comment

by:Contestoas
ID: 24311812
Im putting the formula in Report -> Select Expert -> Formula Workshop -> Selection Formulas -> Record Selection.
It looks like it handles the '-?-' as a pure string since if I change the ? to A it will show the profile containing A.

Are there maybe some properties that has to be turned on for the program to not recognize the ? as string?

Which version of crystal reports are you running? Maybe I have an older one?
I'm running Crystal Reports Basic for Visual Studio 2008 v. 10.5.0.0

Marius
0
 

Author Comment

by:Contestoas
ID: 24311978
Got it to work now, forgot to replace the startswith with like :P

Thanks for all your help :)

Regards
Marius
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question