473,394 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Help with IIF expression in query

newnewbie
I have a query where I need Access to evaluate the "Name" field and return messages "Batch" or "Desktop". The "Name" field contains unique values like

A0612041843574124983.tif#http://fl-jax-sharp/sites% and
2006112200039CIN218.TIF#http://fl-jax-sharp/sites%

Values starting with A are "Desktop", starting with 2006 - "Batch"

I tried IIF expression

IIF([Name]="A*","Desktop", "Batch") and it did not work. My guess is that IIF can only work with exact values in the field (e.g. A, 2006) and cannot incorporate the "starts with" expression....

I also tried exporting the query results in Excel and using IF(A2=A06*,"Desktop", "Batch") and it does not work either for the same reason - it needs exact value and cannot deal with the values"starting with". Or maybe I just do not know and should use some other formula/expression.

I am very new with Access, mostly learning on the job. Please help.

Lena
Dec 5 '06 #1
4 9844
ADezii
8,834 Expert 8TB
I have a query where I need Access to evaluate the "Name" field and return messages "Batch" or "Desktop". The "Name" field contains unique values like

A0612041843574124983.tif#http://fl-jax-sharp/sites% and
2006112200039CIN218.TIF#http://fl-jax-sharp/sites%

Values starting with A are "Desktop", starting with 2006 - "Batch"

I tried IIF expression

IIF([Name]="A*","Desktop", "Batch") and it did not work. My guess is that IIF can only work with exact values in the field (e.g. A, 2006) and cannot incorporate the "starts with" expression....

I also tried exporting the query results in Excel and using IF(A2=A06*,"Desktop", "Batch") and it does not work either for the same reason - it needs exact value and cannot deal with the values"starting with". Or maybe I just do not know and should use some other formula/expression.

I am very new with Access, mostly learning on the job. Please help.

Lena
'Create a Calculated Field and for its value set it to a Public Function with a Name Argument. Analyze the Name within the Function and return the appropriate result. The Calculated Field would look like:

Status: fAnalyzeName([Name]) 'Function returns correct Status based on Name passed to it

NOTE: If the need the Function & Code, please let me known. I'll be glad to
assist...
Dec 5 '06 #2
NeoPa
32,556 Expert Mod 16PB
Try :
Expand|Select|Wrap|Line Numbers
  1. IIF([Name] Like "A*","Desktop", "Batch") 
or, if using ANSI-92 compatibility :
Expand|Select|Wrap|Line Numbers
  1. IIF([Name] Like "A%","Desktop", "Batch") 
Dec 5 '06 #3
IIF([Name] Like "A*","Desktop", "Batch") (without a space before "Batch" WORKED!!!!
THANK YOU!
Lena
Dec 6 '06 #4
This is a little bit beyond my understanding of Access yet :) I tried to create a field, but it did not work for me....Anyways, the IIF function worked :)

'Create a Calculated Field and for its value set it to a Public Function with a Name Argument. Analyze the Name within the Function and return the appropriate result. The Calculated Field would look like:

Status: fAnalyzeName([Name]) 'Function returns correct Status based on Name passed to it

NOTE: If the need the Function & Code, please let me known. I'll be glad to
assist...
Dec 6 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: John Baker | last post by:
Hi: As those who have looked at this newsgroup recently will realize, I am a neophyte with Access, although I have experienced with Approach (the Lotus product). There are things I could easily...
10
by: Randy Harris | last post by:
I imported records into a table, later found out that many of them had trailing spaces in one of the fields. If I'd caught it sooner, I could have trimmed the spaces before the import. This...
1
by: ED | last post by:
I am currently developing a database that will spit out job completion stats each day of a given month. I have a table that has lists the number 1 through 31. I am using this as a static table. ...
7
by: rguarnieri | last post by:
Hi! I'm trying to create a query with a boolean expression like this: select (4 and 1) as Value from Table1 this query return always -1, but when I make the same calculation in visual...
6
by: leeg | last post by:
Help please. Apologies but I am poor in access and programming :o) and am having trouble getting my head around this one!!...again!!! I need to have a query or report to flag up someone who has...
47
by: Jo | last post by:
Hi there, I'm Jo and it's the first time I've posted here. I'm in process of creating a database at work and have come a little unstuck.....I'm a bit of a novice and wondered if anyone could...
28
by: Marc Gravell | last post by:
In Linq, you can apparently get a meaningful body from and expression's .ToString(); random question - does anybody know if linq also includes a parser? It just seemed it might be a handy way to...
7
by: John | last post by:
I have a table with amongst others 2 fields: DateIn and DateOut. The idea is to make a chart that shows the average number of days it takes for a request to be answered. I'm planning to make a...
1
by: RussCRM | last post by:
I need some help getting unique records from our database! I work for a small non-profit homeless shelter. We keep track of guest information as well as what services we have offered for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.