IIf statement in Criteria to show all

kelvin2088

Registered User.
Local time
Today, 12:46
Joined
Nov 23, 2010
Messages
18
I'm working on a published sharepoint web access database, writing a criteria expression in data source of a combo box.

The field I'm setting criteria is called SharePointAuthor.

I wrote this critea:
IIf(CurrentWebUser(1)="John Doe","*",CurrentWebUser(1))

Trying to show all records when currentwebuser is John Doe, otherwise, show only records created by currentwebuser.

Funny thing is that it turns out "John Doe" couldn't see any records, while other users can see their own records as expected.

Any suggestion??
 
Gonna have to see the rest of the code.
 
Gonna have to see the rest of the code.

There's no other code, just fairly simple query.

The expression is the only code in there.
 
That's not a query. Minimum you need SELECT and FROM clauses. Your's will also have a WHERE.
 
That's not a query. Minimum you need SELECT and FROM clauses. Your's will also have a WHERE.

Here's my query:
2cg1w06.jpg
 
If you use the Like keyword before your criteria it should work:

Like IIf(CurrentWebUser(1)="UserNameHere","*",CurrentWebUser(1))
 
Thanks! I tried, however, it shows invalid syntax.

I'm coding this in a web form, and "Like" is not in the function library.


If you use the Like keyword before your criteria it should work:

Like IIf(CurrentWebUser(1)="UserNameHere","*",CurrentWebUser(1))
 
I'm not entirely clear where you are using this. But if you place my code into that query you posted a screen shot of it should work. 'Like' is part of SQL (all flavors of it), not whatever coding library you are using.
 
I'm not entirely clear where you are using this. But if you place my code into that query you posted a screen shot of it should work. 'Like' is part of SQL (all flavors of it), not whatever coding library you are using.

that's so weird...
it's not working in the criteria textbox that i showed in attached picture.
is it because i'm putting it in a control of a webform??
 
It might be. Again, not entirely certain the type of environment its ultimately being rendered at (Sharepoint, webform, etc.). Whatever the system is, ultimately you're building an SQL string to execute. That string needs to be properly formed and that really relies on the system building it.
 
It might be. Again, not entirely certain the type of environment its ultimately being rendered at (Sharepoint, webform, etc.). Whatever the system is, ultimately you're building an SQL string to execute. That string needs to be properly formed and that really relies on the system building it.

It'll be used in access published sharepoint site.

"Like" is not recognized by query editor and it won't allow me to save to query.
 
Can you post another screenshot with your attempt to use the LIKE keyword?
 
Can you post another screenshot with your attempt to use the LIKE keyword?

Oh My God It worked!!!
I just got rid off the space between the code that you provided and i worked i think!! thank you so much!!:D
 

Users who are viewing this thread

Back
Top Bottom