Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / July 2007

Tip: Looking for answers? Try searching our database.

Option group values with Iif statement

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kevin - 24 Jul 2007 15:28 GMT
I'm trying to run a query from a form where the user fills in various
parameters with option groups.

The table contains a several different values (ranging from 5.5 to 9) in a
particular field, and I want the query to group them in the query so that all
values from 5.5 to 7 come up in one instance, and all the values from 8 to 9
in another.

In the query grid, if I simply enter, "Between 5.5 And 7", the query runs as
expected and returns all records where the value is within those parameters.
However, if I use an IIf statement such as:

IIf([Forms]![frmRunTrackModelQuery]![fraDistance]=1,Between 5.5 And
7,Between 8 And 9)

... the query returns no records whatsoever.

All attempts at using different sorts of bracked, quotes, etc., have failed.
What am I doing wrong?

Kevin
Klatuu - 24 Jul 2007 15:46 GMT
BETWEEN IIf([Forms]![frmRunTrackModelQuery]![fraDistance]=1, 5.5, 7) AND
IIf(Forms!frmRunTrackModelQuery=1, 8, 9)

Signature

Dave Hargis, Microsoft Access MVP

> I'm trying to run a query from a form where the user fills in various
> parameters with option groups.
[quoted text clipped - 17 lines]
>
> Kevin
Kevin - 24 Jul 2007 16:50 GMT
Almost, but not quite.

The statement returns values between 7 and 9 or between 5.5 and 9. I'm
looking to get the records from 5.5 to 7, or from 8 to 9. By changing the
statement slightly, I get better results but still not perfect:

Between IIf([Forms]![frmRunTrackModelQuery]![fraDistance]=1,5.5,8) And
IIf([Forms]![frmRunTrackModelQuery]=1,7,9)

This returns the records between 8 and 9 correctly, but the True part
returns all records from 5.5 to 9.

> BETWEEN IIf([Forms]![frmRunTrackModelQuery]![fraDistance]=1, 5.5, 7) AND
> IIf(Forms!frmRunTrackModelQuery=1, 8, 9)
[quoted text clipped - 20 lines]
> >
> > Kevin
Klatuu - 24 Jul 2007 16:54 GMT
Between IIf([Forms]![frmRunTrackModelQuery]![fraDistance]=1,5.5,8) And
IIf([Forms]![frmRunTrackModelQuery]=1,7,9)

Shouldn't both comparisons be the same?

[Forms]![frmRunTrackModelQuery]![fraDistance]

[Forms]![frmRunTrackModelQuery]

Signature

Dave Hargis, Microsoft Access MVP

> Almost, but not quite.
>
[quoted text clipped - 32 lines]
> > >
> > > Kevin
Kevin - 24 Jul 2007 17:10 GMT
Yep. That's got it. Many thanks.

Kevin

> Between IIf([Forms]![frmRunTrackModelQuery]![fraDistance]=1,5.5,8) And
> IIf([Forms]![frmRunTrackModelQuery]=1,7,9)
[quoted text clipped - 41 lines]
> > > >
> > > > Kevin
Dale Fye - 24 Jul 2007 17:06 GMT
Kevin,

If the field contains decimal values, then you could be missing quite a few
buy setting your ranges between 5.5 and 7 or between 8 and 9.  What about the
values between 7 and 8?

Dale
Signature

Email address is not valid.
Please reply to newsgroup only.

> Almost, but not quite.
>
[quoted text clipped - 32 lines]
> > >
> > > Kevin
Klatuu - 24 Jul 2007 17:12 GMT
Good catch, Dale.  Excellent question.
Signature

Dave Hargis, Microsoft Access MVP

> Kevin,
>
[quoted text clipped - 40 lines]
> > > >
> > > > Kevin
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.