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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find the negative array formula

Status
Not open for further replies.

lareya

Technical User
Jan 30, 2003
49
US
Hi all,
I have some code that works.
Code:
WhileReadingRecords;
Local StringVar strValidate2;

IF {POST_RESOURCE.ROLE_CODE} in [1,64] then // No Provider Code
     if strValidate2 = "" Then
        strValidate2 :=  'Please Check the Provider Field'  
     else          strValidate2 :=  strValidate2 & chr(13)& chr(13)  & 'Please Check the Provider Field';

IF {POST_RESOURCE.ROLE_CODE} in [12]  then //No Circ Staff Code
     if strValidate2 = "" Then
        strValidate2 :=  'Please Check the RN Staff Field'  
     else          strValidate2 :=  strValidate2 & chr(13)& chr(13)  & 'Please Check the RN Staff Field';

);
strValidate2;
But the problem is that the formula that works does the opposite of what I need it to do. If the role code is there, it gives the error message, but I need to check for the negative. Like the first example. I need to have it check that it is NOT in code [1,64], but I can't seem to find how to check it. I tried these (two formulas below), but got errors. I can't just look for an empty field, cuz it could have several role codes. I just need to check that these specific role codes are present so that I can give an error message if they are not present.
Code:
 IF {POST_RESOURCE.ROLE_CODE} <> in [1,64] then // No Provider Code
     if strValidate2 = "" Then
        strValidate2 :=  'Please Check the Provider Field'  
     else          strValidate2 :=  strValidate2 & chr(13)& chr(13)  & 'Please Check the Provider Field';
Code:
IF {POST_RESOURCE.ROLE_CODE} Not( in [1,64] )then // No Provider Code
     if strValidate2 = "" Then
        strValidate2 :=  'Please Check the Provider Field'  
     else          strValidate2 :=  strValidate2 & chr(13)& chr(13)  & 'Please Check the Provider Field';
Thanks for your help!

Lareya



++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Crystal 8.5; SQL database; MS Windows 2K; ORSOS/One Call Hospital Scheduling System v10.1.2; Huge Newbie to Crystal! Operating Room RN Analyst
 
Dear Lareya,

It is not doing the opposite, it is doing exactly what you are telling it to do.

Here is the logic of your code as written: If the Role Code is equal to 1 or 64 then check to see if the strValidate2 field is blank and if it is assign the value to strvalidate2 of 'Please check the provider field'. When your code isn't in 1, 64, it then returns (the else part) 2 carriage returns concatentated to the phrase 'Please check the provider code.

Since you haven't assigned strvalidate2 any value, at the point you check it, it is indeed blank. So your code always returns the phrase'Please check provider field'.

You then go on to do the same thing for when the code is 12.

In either case the way your code reads, you will always return the "error message".

I don't think you even need the variable here especially since as used in your code.

Try something like this instead:

Select {POST_RESOURCE.ROLE_CODE}

case 1,64 : "Please check the Provider field"
case 12 : "Please check the RN Staff Field"
default : "" //no value returned

However, if you did want to use a variable to limit your typing because there are lots of codes and these are just two examples, something like this might be appropriate:


local stringvar strvalidate2 :=
(select {POST_RESOURCE.ROLE_CODE}
case 1,64 : 'the Provider field'
case 12 : 'the RN Staff Field'
default : '' //no value
;)

if ({POST_RESOURCE.ROLE_CODE} in [1,64,12]
then 'Please check ' & strvalidate2
else 'whatever you want otherwise'

By the way, the proper way to test not is as follows:
not ({POST_RESOURCE.ROLE_CODE} in [1,64])

I hope that helps.

Regards,

ro


Rosemary Lieberman
rosemary-at-microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.

You will get answers more quickly if you read this before posting: faq149-3762
 
Okay, I understand a bit more. The problem is that when I usually check for a code file I check if it is a empty/null field or if there is something in it. it would look like this:
Code:
if {POST_RESOURCE.ROLE_CODE}= 1 then "I am not a empty field " Thus I don't generate a error msg.
if isnull({POST_RESOURCE.ROLE_CODE) or if {POST_RESOURCE.ROLE_CODE}= 1 then "I am an empty field" and a error msg is generated
However, Now I am actually checking for what the role code is in this particular field either 1 or 64. But when I write this formula:
Code:
IF {POST_RESOURCE.ROLE_CODE}in [1,64] 
then // Check for a Provider Code
    "Provider Here"
    else
    "Need a Provider"
But regardless if I select a record with or without a provider I get the error message that "Need a Provider".
this formula works:
Code:
if ({POST_RESOURCE.ROLE_CODE}in[1, 2,3,4,5,6,7,62,64,68]) then ({STAFF.NAME}+totext(":   ")+ {CODES_ROLE.DESCRIPTION})
So I can verify that a provider is present or not. (the other role codes are for other types of providers. The only one that pertain to Provider is 1 & 64. so on the chart I get John Doe : Provider.

Can someone figure out howcome my formula to check and see if the role code is present (1 & 64) doesn't appear to work even tho the last formula works? The last formula is a subreport, and in a detail section. The error msg formula's are on the main report and in a header section.

Thanks a lot!

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Crystal 8.5; SQL database; MS Windows 2K; ORSOS/One Call Hospital Scheduling System v10.1.2; Huge Newbie to Crystal! Operating Room RN Analyst
 
Dear lareya,

I am afraid you lost me.

Rather than stating what you think the formulas should be, why don't you state what you actually need to do.

For example, if the {POST_RESOURCE.ROLE_CODE} is null I need to return this and if it is not null and the code is either 1 or 64 return this otherwise I need the formulas to say something else.

Why don't you do this. Place the actual {POST_RESOURCE.ROLE_CODE} field on the report. Now place your formula right next to it. If the field contains a 1 or a 64 and you return the error message, then that would give us info and if it returns "provider here" then that would give us info.

Since you state the very last formula works, I think you will find that the codes returned are those other than 1 or 64 and you will have to code the formulas to handle that.

regards,

ro

Rosemary Lieberman
rosemary-at-microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.

You will get answers more quickly if you read this before posting: faq149-3762
 
okay,

I need the formula to check the different role codes. for the example I have been using for Provider I need to check for Role code 1 or 64. If they are not present, then I need to give the error msg "please check a Provider". I have 4 Roles to check for:
Provider [1,64]
Anesthesiologist [4,6,7,62,68]
Scrub [9,10,12]
Circ [12]

Those are all the People I am checking for with all the possible role codes they can have.

My formula don't work. It gives me the error code regardless if the role code is in the record or not. I have 2 test records. 1 has all the role codes filled in and the other has none of the role codes filled in. With both records, I get the error msg. The Room Number works however.

I have placed the actual role code in the report. That is the last formula that works corrrectly that I showed above which gives me the correct readings when I have a provider or not. I just need to separate out the anesthesiologist with the Provider, and separate the scrub with the circ. That is why I am confused because I am using the same fields, and it works one place and not the other.
Code:
 WhileReadingRecords;
 Local StringVar strValidate2;
 (
IF {POST_CASE.ROOM_ID} = "" then //empty room number
    if strValidate2 = "" Then
        strValidate2 := 'Please Check the Room Number Field'   
   else         strValidate2 :=  strValidate2 & chr(13)& chr(13)  & 'Please Check the Room Number Field';
   
IF Not({POST_RESOURCE.ROLE_CODE} in [6,1]) then // No Provider Code
     if strValidate2 = "" Then
        strValidate2 :=  'Please Check the Provider Field'  
     else          strValidate2 :=  strValidate2 & chr(13)& chr(13)  & 'Please Check the Provider Field';

IF Not({POST_RESOURCE.ROLE_CODE} in [4,6,7,62]) then // No Anesthesiologist Code
     if strValidate2 = "" Then
        strValidate2 :=  'Please Check the Anesthesiologist Field'  
     else          strValidate2 :=  strValidate2 & chr(13)& chr(13)  & 'Please Check the Anesthesiologist Field';

IF Not({POST_RESOURCE.ROLE_CODE} in [9,10,72])  then //No Scrub Staff Code
     if strValidate2 = "" Then
        strValidate2 :=  'Please Check the Scrub Field'  
     else          strValidate2 :=  strValidate2 & chr(13)& chr(13)  & 'Please Check the Scrub Field';

IF Not({POST_RESOURCE.ROLE_CODE} in [12])  then //No Circ Staff Code
     if strValidate2 = "" Then
        strValidate2 :=  'Please Check the RN Staff Field'  
     else          strValidate2 :=  strValidate2 & chr(13)& chr(13)  & 'Please Check the RN Staff Field';

);
strValidate2;




++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Crystal 8.5; SQL database; MS Windows 2K; ORSOS/One Call Hospital Scheduling System v10.1.2; Huge Newbie to Crystal! Operating Room RN Analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top