If - Then - Else in report ?

  • Thread starter Thread starter Gina
  • Start date Start date
G

Gina

Hi.

My report is based on a param query. textbox1 shows these 2 params. ok so
far. But it's a bit ugly to see just numbers in the box instead of
something more informable on a report.
So I thought can I define an unbound textbox2 and to show a more human
expression ?

Is there a possibility to do:

=If([textbox1]=0;[textbox2].Text="OK";[textbox2].Text="Not OK")

I get #error for that textbox2
How could I solve this ??

Thanks for your help

Gina
 
Are you placing this in Textbox2? If so, it would just be

=If([textbox1]=0;"OK";"Not OK")
 
You could place something like the following into your form's On Current event:
If Me.textbox1 = 0 Then Me.textbox2 = "OK" Else Me.textbox2 = "Not OK"
That would all be on one line. This assumes that 0 is a number. If 0 is
text you would place it in quotes. If you mean to say that if there is
nothing in me.textbox1 (although it is hard to see how the parameter could be
empty)you could have in the form's On Current event something like:

If IsNull(Me.textbox1) Then
Me.textbox2 = "OK"
Else: Me.textbox2 = "Not OK"
End If
 
Wanye, thanks so much ... it works with the If

Gina :-)

Wayne Morgan said:
Are you placing this in Textbox2? If so, it would just be

=If([textbox1]=0;"OK";"Not OK")

--
Wayne Morgan
MS Access MVP


Gina said:
Hi.

My report is based on a param query. textbox1 shows these 2 params. ok
so
far. But it's a bit ugly to see just numbers in the box instead of
something more informable on a report.
So I thought can I define an unbound textbox2 and to show a more human
expression ?

Is there a possibility to do:

=If([textbox1]=0;[textbox2].Text="OK";[textbox2].Text="Not OK")

I get #error for that textbox2
How could I solve this ??

Thanks for your help

Gina
 
Bruce, thanks for your answer.

problem is that I am in a report .... so is there something similar to a on
current event of a form ??
sorry, I am fairly new to all these features of access

Gina

BruceM said:
You could place something like the following into your form's On Current event:
If Me.textbox1 = 0 Then Me.textbox2 = "OK" Else Me.textbox2 = "Not OK"
That would all be on one line. This assumes that 0 is a number. If 0 is
text you would place it in quotes. If you mean to say that if there is
nothing in me.textbox1 (although it is hard to see how the parameter could be
empty)you could have in the form's On Current event something like:

If IsNull(Me.textbox1) Then
Me.textbox2 = "OK"
Else: Me.textbox2 = "Not OK"
End If



Gina said:
Hi.

My report is based on a param query. textbox1 shows these 2 params. ok so
far. But it's a bit ugly to see just numbers in the box instead of
something more informable on a report.
So I thought can I define an unbound textbox2 and to show a more human
expression ?

Is there a possibility to do:

=If([textbox1]=0;[textbox2].Text="OK";[textbox2].Text="Not OK")

I get #error for that textbox2
How could I solve this ??

Thanks for your help

Gina
 
The most similar to the Current event of a form would be the Format event of
the report section. This event exists for each section of the report.
 
Gina, I see that you specified that it was a report. I had just finished
something very similar in a form, and passed along what I had just done
without paying enough attention to what you actually asked. Wayne's
suggestion about using the text box is probably your best choice. Sorry if I
sent you on a fishing expedition.


Gina said:
Bruce, thanks for your answer.

problem is that I am in a report .... so is there something similar to a on
current event of a form ??
sorry, I am fairly new to all these features of access

Gina

BruceM said:
You could place something like the following into your form's On Current event:
If Me.textbox1 = 0 Then Me.textbox2 = "OK" Else Me.textbox2 = "Not OK"
That would all be on one line. This assumes that 0 is a number. If 0 is
text you would place it in quotes. If you mean to say that if there is
nothing in me.textbox1 (although it is hard to see how the parameter could be
empty)you could have in the form's On Current event something like:

If IsNull(Me.textbox1) Then
Me.textbox2 = "OK"
Else: Me.textbox2 = "Not OK"
End If



Gina said:
Hi.

My report is based on a param query. textbox1 shows these 2 params. ok so
far. But it's a bit ugly to see just numbers in the box instead of
something more informable on a report.
So I thought can I define an unbound textbox2 and to show a more human
expression ?

Is there a possibility to do:

=If([textbox1]=0;[textbox2].Text="OK";[textbox2].Text="Not OK")

I get #error for that textbox2
How could I solve this ??

Thanks for your help

Gina
 
Back
Top