472,783 Members | 953 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,783 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 9780
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,534 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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.