Conditional parameter value

L

Leslie Isaacs

Hello All

I have a textbox on a report with the following expression:

=IIf([bacs direct]=True,UCase([Enter pasword for WAGES]))

The problem is that the parameter value [Enter pasword for WAGES] is
requested whether or not [bacs direct]=True.
I only want the parameter value to be requested if [bacs direct]=True - if
[bacs direct]=False I do not want to to be asked for a value for [Enter
pasword for WAGES].

I'm sure this must be possible, but I cannot see how.
Hope someone can help.
Many thanks
Leslie Isaacs
 
T

tina

you might try setting the value of the textbox in code, probably using the
OnPrint or OnFormat event procedure of the report section that the textbox
control sits in, as

If Me![bacs direct] = True Then
Me!TextboxName = InputBox("Enter pasword for WAGES")
End If

hth
 
P

Pat Hartman\(MVP\)

The problem is the way the IIf() is evaluated in VBA. When you use this
function in VBA, ALL arguments are evaluated, not just the ones in the true
path. Since all arguments are always evaluated, the prompt always happens.
Using an If Then Else in a code module as suggested by Tina will solve the
problem.

When you use the IIf() in a query, only the true path is evaluated so you
don't have a problem.
 
L

Leslie Isaacs

Tina

Many thanks for your help.

Your suggestion worked fne, except that initially I found that when [bacs
direct] = True the InputBox("Enter pasword for WAGES") was being displayed 3
times, and only the last value I entered was appearing on the form! Also,
the InputBox was re-displayed when I clicked to view page 2. The control was
in the report header. I have stopped these repititions by adding " And
IsNull(Me!TextboxName) " to the " If Me![bacs direct] = True ".
I am curious to know why I was getting the repititions!

Many thanks once again.
Les


tina said:
you might try setting the value of the textbox in code, probably using the
OnPrint or OnFormat event procedure of the report section that the textbox
control sits in, as

If Me![bacs direct] = True Then
Me!TextboxName = InputBox("Enter pasword for WAGES")
End If

hth


Leslie Isaacs said:
Hello All

I have a textbox on a report with the following expression:

=IIf([bacs direct]=True,UCase([Enter pasword for WAGES]))

The problem is that the parameter value [Enter pasword for WAGES] is
requested whether or not [bacs direct]=True.
I only want the parameter value to be requested if [bacs direct]=True - if
[bacs direct]=False I do not want to to be asked for a value for [Enter
pasword for WAGES].

I'm sure this must be possible, but I cannot see how.
Hope someone can help.
Many thanks
Leslie Isaacs
 
T

tina

I am curious to know why I was getting the repititions!

probably because Access sets up the report sections separately for each
page. i don't really have a clear picture of what you're doing, but you
might try putting the code in the report's Open event, instead of in the
section's Format or Print event.

hth


Leslie Isaacs said:
Tina

Many thanks for your help.

Your suggestion worked fne, except that initially I found that when [bacs
direct] = True the InputBox("Enter pasword for WAGES") was being displayed 3
times, and only the last value I entered was appearing on the form! Also,
the InputBox was re-displayed when I clicked to view page 2. The control was
in the report header. I have stopped these repititions by adding " And
IsNull(Me!TextboxName) " to the " If Me![bacs direct] = True ".
I am curious to know why I was getting the repititions!

Many thanks once again.
Les


tina said:
you might try setting the value of the textbox in code, probably using the
OnPrint or OnFormat event procedure of the report section that the textbox
control sits in, as

If Me![bacs direct] = True Then
Me!TextboxName = InputBox("Enter pasword for WAGES")
End If

hth


Leslie Isaacs said:
Hello All

I have a textbox on a report with the following expression:

=IIf([bacs direct]=True,UCase([Enter pasword for WAGES]))

The problem is that the parameter value [Enter pasword for WAGES] is
requested whether or not [bacs direct]=True.
I only want the parameter value to be requested if [bacs
direct]=True -
if
[bacs direct]=False I do not want to to be asked for a value for [Enter
pasword for WAGES].

I'm sure this must be possible, but I cannot see how.
Hope someone can help.
Many thanks
Leslie Isaacs
 
L

Leslie Isaacs

Tina
You were absolutely right: many thanks
Les


tina said:
I am curious to know why I was getting the repititions!

probably because Access sets up the report sections separately for each
page. i don't really have a clear picture of what you're doing, but you
might try putting the code in the report's Open event, instead of in the
section's Format or Print event.

hth


Leslie Isaacs said:
Tina

Many thanks for your help.

Your suggestion worked fne, except that initially I found that when [bacs
direct] = True the InputBox("Enter pasword for WAGES") was being
displayed 3
times, and only the last value I entered was appearing on the form! Also,
the InputBox was re-displayed when I clicked to view page 2. The control was
in the report header. I have stopped these repititions by adding " And
IsNull(Me!TextboxName) " to the " If Me![bacs direct] = True ".
I am curious to know why I was getting the repititions!

Many thanks once again.
Les


tina said:
you might try setting the value of the textbox in code, probably using the
OnPrint or OnFormat event procedure of the report section that the textbox
control sits in, as

If Me![bacs direct] = True Then
Me!TextboxName = InputBox("Enter pasword for WAGES")
End If

hth


Hello All

I have a textbox on a report with the following expression:

=IIf([bacs direct]=True,UCase([Enter pasword for WAGES]))

The problem is that the parameter value [Enter pasword for WAGES] is
requested whether or not [bacs direct]=True.
I only want the parameter value to be requested if [bacs
direct]=True -
if
[bacs direct]=False I do not want to to be asked for a value for [Enter
pasword for WAGES].

I'm sure this must be possible, but I cannot see how.
Hope someone can help.
Many thanks
Leslie Isaacs
 
T

tina

you're welcome, glad we figured it out. :)


Leslie Isaacs said:
Tina
You were absolutely right: many thanks
Les


tina said:
I am curious to know why I was getting the repititions!

probably because Access sets up the report sections separately for each
page. i don't really have a clear picture of what you're doing, but you
might try putting the code in the report's Open event, instead of in the
section's Format or Print event.

hth


Leslie Isaacs said:
Tina

Many thanks for your help.

Your suggestion worked fne, except that initially I found that when [bacs
direct] = True the InputBox("Enter pasword for WAGES") was being
displayed 3
times, and only the last value I entered was appearing on the form! Also,
the InputBox was re-displayed when I clicked to view page 2. The
control
was
in the report header. I have stopped these repititions by adding " And
IsNull(Me!TextboxName) " to the " If Me![bacs direct] = True ".
I am curious to know why I was getting the repititions!

Many thanks once again.
Les


you might try setting the value of the textbox in code, probably
using
the
OnPrint or OnFormat event procedure of the report section that the textbox
control sits in, as

If Me![bacs direct] = True Then
Me!TextboxName = InputBox("Enter pasword for WAGES")
End If

hth


Hello All

I have a textbox on a report with the following expression:

=IIf([bacs direct]=True,UCase([Enter pasword for WAGES]))

The problem is that the parameter value [Enter pasword for WAGES] is
requested whether or not [bacs direct]=True.
I only want the parameter value to be requested if [bacs direct]=True -
if
[bacs direct]=False I do not want to to be asked for a value for [Enter
pasword for WAGES].

I'm sure this must be possible, but I cannot see how.
Hope someone can help.
Many thanks
Leslie Isaacs
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top