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  

Please Help!? Show/Don't show fields



 
 
Thread Tools Display Modes
  #1  
Old September 16th, 2005, 02:14 PM
A. Smart
external usenet poster
 
Posts: n/a
Default Please Help!? Show/Don't show fields

How do I use criteria to show or not show a fiel, for example, I have an IIf
function:

IIf([Forms]![FormName]![ComboBox]="Text",([Query].[Fieldname])=True)

I would only like to show this field when the criteria is met and block out
other criteria. Thank you in advance!
--
Regards

Ashley Smart
  #2  
Old September 16th, 2005, 03:28 PM
Jeff Boyce
external usenet poster
 
Posts: n/a
Default

Are you saying you want a query to change which fields it includes,
depending on the value on a form?

One approach would be to use a SQL statement that you build "on the fly"
from the form itself.

Regards

Jeff Boyce
Access MVP

"A. Smart" wrote in message
...
How do I use criteria to show or not show a fiel, for example, I have an
IIf
function:

IIf([Forms]![FormName]![ComboBox]="Text",([Query].[Fieldname])=True)

I would only like to show this field when the criteria is met and block
out
other criteria. Thank you in advance!
--
Regards

Ashley Smart



  #3  
Old September 16th, 2005, 03:43 PM
A. Smart
external usenet poster
 
Posts: n/a
Default

Could you give me an example please, I'm not hot on SQL statements!
Cheers
--
Regards

Ashley Smart


"Jeff Boyce" wrote:

Are you saying you want a query to change which fields it includes,
depending on the value on a form?

One approach would be to use a SQL statement that you build "on the fly"
from the form itself.

Regards

Jeff Boyce
Access MVP

"A. Smart" wrote in message
...
How do I use criteria to show or not show a fiel, for example, I have an
IIf
function:

IIf([Forms]![FormName]![ComboBox]="Text",([Query].[Fieldname])=True)

I would only like to show this field when the criteria is met and block
out
other criteria. Thank you in advance!
--
Regards

Ashley Smart




  #4  
Old September 16th, 2005, 03:47 PM
Chaim
external usenet poster
 
Posts: n/a
Default

Are you trying to dynamically alter the select list of a query? You can't do
it this way. You can try nested IIFs by using the false option of the IIF
statement
(IIF (expression, true-value, false-value)) as below:

select IIF (Forms!FormName!ComboBox = "text", fieldname1, IIF
(Forms!FormName!ComboBox = "text", fieldname2,"") etc.

This will work but you're going to drive yourself crazy balancing
parentheses if there are too many options (unless you've got a reasonable
editor that balances parentheses for you), you need one of these nested IIFs
for each option in the combo box, and you've got to remember to change the
query if the set of options changes ("text" doesn't have a match- a zombie;
or the text changes). It gets really screwy if you have to worry about the
',' field separators, although with a ComboBox you only have a single
selection, so you won't have to.

Good Luck!
--

Chaim


"A. Smart" wrote in message
...
How do I use criteria to show or not show a fiel, for example, I have an

IIf
function:

IIf([Forms]![FormName]![ComboBox]="Text",([Query].[Fieldname])=True)

I would only like to show this field when the criteria is met and block

out
other criteria. Thank you in advance!
--
Regards

Ashley Smart



  #5  
Old September 16th, 2005, 04:31 PM
Jeff Boyce
external usenet poster
 
Posts: n/a
Default

Your query is actually a SQL statement, and you can see it by changing the
view of your query in design mode to SQL.

A "dynamic" SQL statement would be build in code, behind the form, probably
on a command button.

You'll need to work in both SQL and in VBA to pull this off.

Your SQL statement would be "assembled" by using an If ... Then statement
in code to check for the value of the form's control, then include (or not)
the reference to the field as part of the SELECT clause -- for example:

If Me!chkMyCheckBox = True Then
strSQL = strSQL & ", MyQueryField"
End If

Good luck!

Jeff Boyce
Access MVP

"A. Smart" wrote in message
...
Could you give me an example please, I'm not hot on SQL statements!
Cheers
--
Regards

Ashley Smart


"Jeff Boyce" wrote:

Are you saying you want a query to change which fields it includes,
depending on the value on a form?

One approach would be to use a SQL statement that you build "on the fly"
from the form itself.

Regards

Jeff Boyce
Access MVP

"A. Smart" wrote in message
...
How do I use criteria to show or not show a fiel, for example, I have
an
IIf
function:

IIf([Forms]![FormName]![ComboBox]="Text",([Query].[Fieldname])=True)

I would only like to show this field when the criteria is met and block
out
other criteria. Thank you in advance!
--
Regards

Ashley Smart






 




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

Similar Threads
Thread Thread Starter Forum Replies Last Post
use a recordset to determine fields to show Noemi Setting Up & Running Reports 1 April 10th, 2005 02:14 AM
Show multiple fields in combo box Lisa Using Forms 3 April 5th, 2005 10:45 PM
Link a query to show more fields Ray Running & Setting Up Queries 5 April 5th, 2005 05:18 AM
Additional fields for form based parameter query/null fields geeksdoitbetter Running & Setting Up Queries 2 January 7th, 2005 10:05 PM
how to show fields when u click a button mimi General Discussion 1 June 23rd, 2004 09:47 AM


All times are GMT +1. The time now is 01:29 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.