label visibility based on report field?

B

Brook

hello all..

I have an invoice report that I use for both sold invoices and conignment
invoices, and a field on my report called invoicetype (with is either "Sold"
or "Consignment"..
And two labels: "Invoice" - named invoicelable and "Consignment Invoice" -
named consignlabel

I would like the Invoice label to be visible if the invoice type is "Sold"
and the Conignment Invoice Lable to be invisible and visa versa?

I tried the following:

If invoicetype = "Sold" Then
invoicelabel.visible = True
consignlabel.visible = False
Else
invoicelabel.visible = False
consignlabel.visible = True

End if
End IF

I tried to enter this code in the code of the form, but was unsuccessfull
in getting it to work ?

Any ideas?

Thanks,

Brook
 
R

Rick B

You say that you tried the following code, but you don't tell us where you
put that code. What event?


If it were me, I'd just add an unbound field to my report and include an if
statement to say IF invoice type = Sold, then print Invoice otherwise print
Consignment invoice. Something lik...


= IF([invoicetype] = "Sold","Invoice","Consignment Invoice")
 
B

Brook

Thanks for the reply Rick,

In my original post I had that I tried the code in the code for the report
itself, but beyond that.

I tried your suggested code, which I should have thought of instead of
trying to make things so much more difficult, but then I got an "Enter
parameter value", then had the word 'if'.

I changed my code to the following and it worked fine:

=IIf(([invoicetype])="Sold","Invoice", "Consignment Invoice")

why would that make a difference?

Thanks for your help.

Brook



Rick B said:
You say that you tried the following code, but you don't tell us where you
put that code. What event?


If it were me, I'd just add an unbound field to my report and include an if
statement to say IF invoice type = Sold, then print Invoice otherwise print
Consignment invoice. Something lik...


= IF([invoicetype] = "Sold","Invoice","Consignment Invoice")




--
Rick B



Brook said:
hello all..

I have an invoice report that I use for both sold invoices and conignment
invoices, and a field on my report called invoicetype (with is either "Sold"
or "Consignment"..
And two labels: "Invoice" - named invoicelable and "Consignment Invoice" -
named consignlabel

I would like the Invoice label to be visible if the invoice type is "Sold"
and the Conignment Invoice Lable to be invisible and visa versa?

I tried the following:

If invoicetype = "Sold" Then
invoicelabel.visible = True
consignlabel.visible = False
Else
invoicelabel.visible = False
consignlabel.visible = True

End if
End IF

I tried to enter this code in the code of the form, but was unsuccessfull
in getting it to work ?

Any ideas?

Thanks,

Brook
 
R

Rick B

That is correct. IIF is what you use in a control. IF is what you use in
vba.



--
Rick B



Brook said:
Thanks for the reply Rick,

In my original post I had that I tried the code in the code for the report
itself, but beyond that.

I tried your suggested code, which I should have thought of instead of
trying to make things so much more difficult, but then I got an "Enter
parameter value", then had the word 'if'.

I changed my code to the following and it worked fine:

=IIf(([invoicetype])="Sold","Invoice", "Consignment Invoice")

why would that make a difference?

Thanks for your help.

Brook



Rick B said:
You say that you tried the following code, but you don't tell us where you
put that code. What event?


If it were me, I'd just add an unbound field to my report and include an if
statement to say IF invoice type = Sold, then print Invoice otherwise print
Consignment invoice. Something lik...


= IF([invoicetype] = "Sold","Invoice","Consignment Invoice")




--
Rick B



Brook said:
hello all..

I have an invoice report that I use for both sold invoices and conignment
invoices, and a field on my report called invoicetype (with is either "Sold"
or "Consignment"..
And two labels: "Invoice" - named invoicelable and "Consignment Invoice" -
named consignlabel

I would like the Invoice label to be visible if the invoice type is "Sold"
and the Conignment Invoice Lable to be invisible and visa versa?

I tried the following:

If invoicetype = "Sold" Then
invoicelabel.visible = True
consignlabel.visible = False
Else
invoicelabel.visible = False
consignlabel.visible = True

End if
End IF

I tried to enter this code in the code of the form, but was unsuccessfull
in getting it to work ?

Any ideas?

Thanks,

Brook
 
M

Mike Painter

Brook said:
Thanks for the reply Rick,

In my original post I had that I tried the code in the code for the
report itself, but beyond that.

I tried your suggested code, which I should have thought of instead of
trying to make things so much more difficult, but then I got an "Enter
parameter value", then had the word 'if'.

I changed my code to the following and it worked fine:

=IIf(([invoicetype])="Sold","Invoice", "Consignment Invoice")

why would that make a difference?


You did what Rick wrote rather than what he meant ;)
 

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