473,398 Members | 2,403 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,398 software developers and data experts.

Using Dlookup to generate an IIf statement

Hi All

Apologies if someone has asked this question before, but I have hunted high and low for the solution.

I am relatively new to using access so am not sure if this is possible. I am using MS Access 2003.

I want to use the result of one query as an IIf statement in a calculated field in a new query.

I have tried using dlookup to do this but the result is just the IIf statement posted as a string of text. e.g;

Expr1: Dlookup("[SQL_String]","QRY_CONCAT_SQL_STRING")

Returns

=IIF([PEAK MONTH TOTE CONSUMPTION] BETWEEN 0 AND 1.99, '1A', '1B')

As a text string.

If I pick up the result of SQL_String an use it as an expression in a field it returns what I am after i.e. the result is '1A' or '1b'.
Jun 14 '07 #1
4 2525
puppydogbuddy
1,923 Expert 1GB
Hi All

Apologies if someone has asked this question before, but I have hunted high and low for the solution.

I am relatively new to using access so am not sure if this is possible. I am using MS Access 2003.

I want to use the result of one query as an IIf statement in a calculated field in a new query.

I have tried using dlookup to do this but the result is just the IIf statement posted as a string of text. e.g;

Expr1: Dlookup("[SQL_String]","QRY_CONCAT_SQL_STRING")

Returns

=IIF([PEAK MONTH TOTE CONSUMPTION] BETWEEN 0 AND 1.99, '1A', '1B')

As a text string.

If I pick up the result of SQL_String an use it as an expression in a field it returns what I am after i.e. the result is '1A' or '1b'.

If I understand you correctly, the DLookup on the SQL_String is returning the expression for the SQL string and you are looking for a way to return the result of the expression. Try the Eval function and see if that does what you want.

Eval("[SQL_String]").
Jun 15 '07 #2
Good idea it did not occur to me to try that, unfortunately I get the message;

"The expression is typed incorrectly, or is too complex to be evaluated....."

I know its not the former so I am obviously trying to evaluate too much.

Thanks for the advice though.
Jun 15 '07 #3
puppydogbuddy
1,923 Expert 1GB
Good idea it did not occur to me to try that, unfortunately I get the message;

"The expression is typed incorrectly, or is too complex to be evaluated....."

I know its not the former so I am obviously trying to evaluate too much.

Thanks for the advice though.
Try it this way:

Eval(nz("[SQL_String]",""))
Jun 15 '07 #4
puppydogbuddy
1,923 Expert 1GB
Try it this way:

Eval(nz("[SQL_String]",""))

also, try this:

Eval(CStr(SQL_String))
Jun 15 '07 #5

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

Similar topics

2
by: Ronny Sigo | last post by:
Hello all, I already put the same question, only now I have more to tell ... Although I used this code before in the same routine (only the fieldname of the table differs) ___ at this point in the...
1
by: Thelma Lubkin | last post by:
I am still struggling with trying to match a user supplied string with strings in a field of a table, where spaces are to be ignored. Arno suggested that I use the Dlookup function, but I...
6
by: WWH | last post by:
New to Access and have what should be a simple problem. Have two tables... 1. first table has description of herbs and Chapter+Section number (ie 2.3 - decimal) 2. second table has same...
3
MSeda
by: MSeda | last post by:
I have a loop that is controlled by a Dlookup statement with two criteria. Both criteria fields are checkboxes. I have tried an assortment of quotation marks in the criteria section and cannot get...
2
by: hr833 | last post by:
i'm having trouble with Dlookup.I'm trying to insert a Dlookup statement in a update query, so that the user need not upate each record manually. Supplier Catergory sSupplierName sCatergory ...
13
by: jkimbler | last post by:
As part of our QA of hardware and firmware for the company I work for, we need to automate some testing of devices and firmware. Since not everybody here knows C#, I'm looking to create a new...
2
by: Denise | last post by:
Front end is Access 2002, back end is linked Oracle tables. My users need to describe things in feet and inches and want to use the standard ' and " abbrevations. On a testing form I go to a...
3
by: adigga1 | last post by:
Hello Experts, I'm about to go grey with this dlookup statement: I'm trying to run a dlookup statement, I have the correct expression string, etc. but when I run it under the Immediate window...
5
by: dbrother | last post by:
Access 2003 Win XP Pro SP3 Using SQL /ADO Recordsets in a Do Loop Hello, I'm using a random number generator based on an integer input from a user from a form that will get X number of random...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.