A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

no criteria



 
 
Thread Tools Display Modes
  #1  
Old December 9th, 2009, 03:08 AM posted to microsoft.public.access.queries
seeker
external usenet poster
 
Posts: 133
Default no criteria

the following iif

IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='wholesale',"N",IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='retail',"Y",IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='all',NULL)))

attempts to place no criteria filter in the query when 'all' is found. the
query runs and does not transfer all records to another database. how would
this iif statement look so that 'all' wold not have any criteria in the query.
  #2  
Old December 9th, 2009, 03:52 AM posted to microsoft.public.access.queries
Allen Browne
external usenet poster
 
Posts: 11,706
Default no criteria

The WHERE clause of the query evaluates to an expression that is True or
False (or Null.) You need to craft this expression so that it returns TRUE
when the text box contains All.

Switch the query to SQL View (View menu.)

Locate the WHERE clause, and change it to this kind of thing (replacing
"somefield" with the name of your text field):
WHERE
IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='wholesale',
[somefield]="N",
IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='retail',
[somefield]="Y",
IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='all',TRUE)))

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"seeker" wrote in message
...
the following iif

IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='wholesale',"N",IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='retail',"Y",IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='all',NULL)))

attempts to place no criteria filter in the query when 'all' is found.
the
query runs and does not transfer all records to another database. how
would
this iif statement look so that 'all' wold not have any criteria in the
query.


  #3  
Old December 9th, 2009, 11:14 AM posted to microsoft.public.access.queries
Brian
external usenet poster
 
Posts: 1,396
Default no criteria

It is not quite clear from your post where this statement occurs, but
assuming it is actually in the criteria of the query (i.e. not on a form that
is creating a criteria string), your IIf filters to actual NULL values when
it should be looking for ALL values, which is perhaps best represented by
this: Like '*' (i.e. Like anything)

I did not test this, but it should look something like this:

IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='wholesale',"N",IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='retail',"Y",IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='all',Like '*')))


"seeker" wrote:

the following iif

IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='wholesale',"N",IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='retail',"Y",IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='all',NULL)))

attempts to place no criteria filter in the query when 'all' is found. the
query runs and does not transfer all records to another database. how would
this iif statement look so that 'all' wold not have any criteria in the query.

  #4  
Old December 9th, 2009, 03:05 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default no criteria

You can not put the operator 'Like' inside.
Like
IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='wholesale',"N",IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='retail',"Y",IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='all',"*")))

--
Build a little, test a little.


"Brian" wrote:

It is not quite clear from your post where this statement occurs, but
assuming it is actually in the criteria of the query (i.e. not on a form that
is creating a criteria string), your IIf filters to actual NULL values when
it should be looking for ALL values, which is perhaps best represented by
this: Like '*' (i.e. Like anything)

I did not test this, but it should look something like this:

IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='wholesale',"N",IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='retail',"Y",IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='all',Like '*')))


"seeker" wrote:

the following iif

IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='wholesale',"N",IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='retail',"Y",IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='all',NULL)))

attempts to place no criteria filter in the query when 'all' is found. the
query runs and does not transfer all records to another database. how would
this iif statement look so that 'all' wold not have any criteria in the query.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:16 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.