IIf statment ??

undergrad

Registered User.
Local time
Today, 17:40
Joined
May 29, 2003
Messages
25
i hope this is an easy task

I want to enter an IIF statement into my criteria.

the expression is "chkboxstat=true"

the true part is set the combobox value for the field's criteria
"[Forms]![FrmParam]![CmBxStat]"

the false part would be to leave the criteria alone (that is i don't want criteria for that field anymore).

is this possible and how could i set the flase part to what i want

any help/criticism would be great

thanks!
 
IIf(chkboxstat Is True, [Forms]![FrmParam]![CmBxStat] = [insert filed name here])


Try this, man. I wasn't sure from your question what value you wanted to assign to CmBxStat.


ed
 
this is what i was trying to get at

if my expression was true i wanted the criteria to be the value i had in a combobox (CmBoxStat)

if the expresion was false i did not want any criteria for the query field.

i understand that this may not be possible with and expression, and that i may have to code.

i was hopeing i could use this expression in the criteria box
IIf («expr», «truepart», «falsepart»)

CmBxStat is not a variable it is a value out of a combo box that the user will pick IF he checks its field's checkbox (thus the expression "chkboxstat=true")

i could be way off here. its been known to happen. either way i hope this helps clear stuff up.

thanks again
 
In query Design, try this setting in a column in the grid (using the correct field name):-

Field: IIf([Forms]![FrmParam]![chkboxstat], [FieldName]=[Forms]![FrmParam]![CmBoxStat], True)

Show: uncheck

Criteria: <>False


Note. The word True in the expression returns every record.
 
that was awesome! that is exactley what i needed thank you so much.

now, is it possible for me to modify what you gave me to something like this

IIf([Forms]![FrmParam]![chkboxThermPS],[Forms]![FrmParam]![TxtBoxmintps]<=[Thermal Power Steady, kW#]<=[Forms]![FrmParam]![TxtBoxmaxtps],True)

where instead of letting the field name be what is in one combo box can it be a value between two numerical values entered into two seperate txt boxes.

i tried this and it does something just not what i want. i figure there is some catch to this whole trick you showed me.

regardless the last example was perfect for the first task i had, and i just wanted to say thanks again!
 
Since the expression is used as the criteria for retrieving records from the table, a field name must be used.


And the correct syntax for the value of a field between the values in two text boxes is:-

[FieldName] BETWEEN [Forms]![FrmParam]![TxtBoxmintps] AND [Forms]![FrmParam]![TxtBoxmaxtps]

or this:-

[FieldName] >= [Forms]![FrmParam]![TxtBoxmintps] AND
[FieldName] <= [Forms]![FrmParam]![TxtBoxmaxtps]
 

Users who are viewing this thread

Back
Top Bottom