Use of CASE statement

Hi,

I have a Textbox with source expression Status.

The Status are: Open,Close,Lock…

In my current Form, the status will keep on changing like Open,Close,Lock .

Now i want to use CASE statement as below.

Case Status of:

Open: Message(‘I am in Open state’);

Close: Message(‘I am in Close state’);

Lock: Message(‘I am in Lock state’);

else

Message(‘I am no in any state’);

Is it possible?

where do you want to use it? what problem are you facing?

I want to use this OnAfterGetRecord trigger.

The syntax is correct or not?

I want to know is it possible?

Did you try to write it on trigger?

what error are you getting?

Not quite sure is this is what you are looking for: If your field Status is an Option-field, the you should write the code like this:

::
Case Status of:
Status::Open: Message(‘I am in Open state’);
Status::Close: Message(‘I am in Close state’);

ELSE

::

Hi,

Thanks for replying.

The data type of Status is Code(30).

Please reply what will be the best way.

I don’t want to use If-Else or Nested If-Else.

If it a Code type then user can enter ABC or XYZ also.

what in that case?

The Textbox Status is Not Editable. There is a table for Status with a fixed set of values.

The value will change from code written OnPush.

Please share the idea.

I am waiting for the reply.

Well, the CASE structure will still work … CASE Status OF ‘OPEN’: MESSAGE(‘I’m OPEN’); … END; Though, if we’re to assume that the example you’re giving is actually what you’re trying to accomplish (and not just a made-up example), then why not do something like: MESSAGE(STRSUBSTNO(‘I am in %1 Status.’, Status); This way, you don’t need to test the value of status, nor replicate code that’s pretty much redundant. Now, the real question goes to what it is that you’re actually trying to accomplish. There’s no reason whatsoever to raise a MESSAGE dialog in the OnAfterGetRecord trigger, especially when you consider how the MESSAGE output is delayed until after then end of a process … it doesn’t get raised at the point in code where the command is written. So, what’s your real objective?

Thanks for replying.

My actual objective is to know whether the CASE will work or not?

The syntax i am using is right or wrong?

Read this post

http://www.mibuso.com/forum/viewtopic.php?t=28526

Read this:

http://msdn.microsoft.com/en-us/library/dd339070.aspx

My issue is Resolved.

Actually there was just a syntax error.

I was missing END in using CASE statement.

Thanks to all for replying.