Hi all;
Well, I've had my obligatory hour of Googling, scratching my head and trial and error and now I'm stumped. I'm using the following code as a query parameter: - ALike IIf(IsNull([forms]![frmReportGenerator]![cboMinTotExp]),"%",<[forms]![frmReportGenerator]![cboMinTotExp])
The idea is that if there's value in the field then the parameter is carried into the query. If the box is empty then it's not. Using: - <[forms]![frmReportGenerator]![cboMinTotExp]
as a parameter on its own works fine but then I lose the vital iif() function. But using the iif() function returns no results! When I check back on the query I find that Access has rewritten it to: - ALike IIf(IsNull([forms]![frmReportGenerator]![cboMinTotExp]),"%",([tblCustomers].[TotalExposure])<[forms]![frmReportGenerator]![cboMinTotExp])
which is obvioulsy fishy. Any ideas how I can phrase the original statement in a way that'll work? It's driving me nuts!
11 3670 FishVal 2,653
Recognized Expert Specialist
Close but no cigar. The "blank search parameters" problem was one I solved last week, that at least is working fine now. My problem is how to fit < and > into the TruePart of an iif statement, where the TruePart is a control on a form. Any ideas?
FishVal 2,653
Recognized Expert Specialist
The last post in the thread has a link to other thread. I guess your answer is there.
NeoPa 32,564
Recognized Expert Moderator MVP
You're using IIf() to determine which value to use, yet that's not what your code is doing. It's also trying to change the comparator operator, which doesn't make sense as it's already included as "ALike" ( Using the Right Wildcard Characters in SQL Statements may help).
Can you post the two different WHERE items (including A Op B) that you would expect in the two circumstances so that I can think what it is you may be looking for.
Is this SQL stored as is, or are you working it out in code to be executed afterwards?
NeoPa 32,564
Recognized Expert Moderator MVP @Whizzo
I think your problem is more to do with thinking that even makes sense.
As Mr Spock might say "It's illogical Jim".
Sure it makes sense! Here's how I understand it. An iif statement is made of:
1. Criteria. String to check for validity.
2. Truepart. Return this string/value if (1) is True.
3. Falsepart. Return this string/value if (1) is False.
In this case:
1. Criteria is "Is this [txtTest] empty?"
2. Truepart. "If [txtTest] is empty, return a "%" here." (in this case it's a Criteria box in the Query Builder)
3. Falsepart. "If it's not empty, return "<[txtTest]" (or <"[txtTest]", whichever it may be) into this space.
That makes sense, doesn't it? My problem is getting the iif() statement to phrase the Falsepart in a way that the Query Builder can understand and work with. I'm currently using the above iif method with plain text that doesn't need < and > and its working perfectly. Any ideas? I'm a doctor Jim, not a programmer!
FishVal 2,653
Recognized Expert Specialist
Thanks fish, that's almost the tree I'm barking up but I don't need to let users enter their own operators. The user will supply the number (say 500) and then the iif() statement will supply a Less Than operator. I did try - < IIf(IsNull([forms]![frmReportGenerator]![cboMinTotExp]),"%",<[forms]![frmReportGenerator]![cboMinTotExp])
instead of starting with Alike but the expression was too complicated for Access to process, apparently.
NeoPa 32,564
Recognized Expert Moderator MVP @Whizzo
No (My previous post was a clue).
Why it doesn't make sense may not be so easy to see without direction.
Consider your last statement : @Whizzo
As this is SQL we're working within (NOT some VBA code to create a string which later may be passed to and interpreted by the SQL engine), the comparator (<) within the string, is simply another character of the data. The fact that it is within the return value of a function call (IIf()), tells the SQL engine that it is to be treated as data and not as part of the command structure.
Consider that the return value can be considered to be equivalent to a literal string. In that case it would be equivalent to :
NB : - The '<' is within the text quotes.
- Even if it weren't, you would still end up with 'ALike' and '<' which would not be something the SQL engine could logically process.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: |
last post by:
From ASP I run a query using MIN(some_field/parameter)
Now I need to pass this parameter to the query from ASP code
How do I do that?
Syntax like
MIN( / )
does not work
|
by: WGW |
last post by:
Though I am a novice to MS SQL server (2000 I believe), I can do almost!
everything I need. Maybe not efficiently, but usefully. However, I have
a problem -- a complex query problem...
I can create a parameter query in a stored procedure, but how do I use
the result set of a parameter query in a select query (in the same or
another sp)? In...
|
by: zlatko |
last post by:
There is a form in an Access Project (.adp, Access front end with SQL
Server) for entering data into a table for temporary storing. Then, by
clicking a botton, several action stored procedures (update, append) should
be activated in order to transfer data to other tables.
I tried to avoid any coding in VB, as I am not a professional, but I...
|
by: Lionel B |
last post by:
Greetings,
I am trying to implement "element-wise" arithmetic operators for a class
along the following lines (this is a simplified example):
// ----- BEGIN CODE -----
struct X
{
int a,b;
|
by: Resant |
last post by:
I have a query :
Exec 'Select * From Receiving Where Code In (' + @pCode + ')'
@pCode will contain more than one string parameter, eg : A1, A2, A3
How can i write that parameters, I try use :
set @pCode='A1','A2','A3'
but get an error : Incorrect syntax near ','
| |
by: Zlatko Matiæ |
last post by:
Hi everybody!
Recently I was struggling with client/server issues in MS Access/PostgreSQL
combination.
Although Access is intuitive and easy to use desktop database solution, many
problems appear when someone is trying to use it as front-end for real
server database systems such as PostgreSQL or MySQL.
One of these problems is regarding...
|
by: Mark |
last post by:
Hi
From what I understand, you can pass arrays from classic ASP to .NET using
interop, but you have to change the type of the.NET parameter to object.
This seems to be because classic ASP passes a variant containing an array,
and interop expects a parameter of type object if you are passing a variant
(you are expected to cast it to the...
|
by: ngoodearl |
last post by:
Hi,
I have upsized an access db to a sequel 2000 db. The db is used to perform a series of calculations to get a result. The user inputs the required parameters into a form and the data entered is used in the calculations.
At the moment we have a stored procedure that performs the calculations. This contains 22 queries. The remaining queries...
|
by: Jim Michaels |
last post by:
friend fraction& operator+=(const fraction& rhs);
fraction.h(64) Error: error: 'fraction& operator+=(const fraction&)'
must take exactly two arguments
I practically pulled this out of a C++ book (except for the "friend").
can someone explain why GCC is giving me problems here?
for a += or similar operator, what does a proper declaration...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |