Error: data provider or other service returned an e_fail status in forms

I have a from and the data source is a store procedure (SQL Server).
What happen is if the store procedure is worte like this (Case 1))
the the form will be run and opened without any issue.
If the store prcedure worte like this (Case 2)
Then I will get an error message: "data provider or other service returned an e_fail status ..."

The logic is whenever the user click on the form, the system should recognize the user's rights and run the code at different region which assiged to.
The problem is if I hardcode the region in the sp, the form will run and no error. But if I put the code and let it caculate the user's region, then the error message will display.

Anyone have idea of this type of error message?

many thanks.
// case 1
select * from 
Tables
where Property_Assignments.Region like 'NE'

Open in new window

select * from 
Tables

    WHERE (
              Property_Assignments.Region 
              Like 
			  (
			   CASE WHEN
						 (
                           (
						    SELECT [User_Region]
						    FROM   Users 
						    WHERE  LTRIM(RTRIM([User_Network_ID])) = @OSUserName
						   ) <> 'ALL'
						 ) 
				    THEN 
						 (SELECT [User_Region]
						  FROM   Users 
						  WHERE  LTRIM(RTRIM([User_Network_ID])) = @OSUserName)
                    ELSE '%'
			   END
			  )
          )

Open in new window

FinghtingMiaoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Surone1Commented:
my guess would be it has to do with a reserved word.
do you have a field named "user" in your table by chance?
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
FinghtingMiaoAuthor Commented:
NO, the table users have the following fileds: see attached image.


users.JPG
0
FinghtingMiaoAuthor Commented:
I found out the problem,
the casewhen statement returns a list of data which is same values. But LIKE does not accept a list of data but one sigle value. so I just added a sub-query for casewhen statement. then the error message gone.

But still thank you for your comments!  
0
FinghtingMiaoAuthor Commented:
Still thank you !
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
Microsoft Access

From novice to tech pro — start learning today.