Conditional Text in textbox control of continuous form

J

juvi

Hello,

I read a lot of things about conditional formating (color, font...) but how
can I make a condition like: if text="ST" then text="PC"

So I just want to show other text in the specific textboxes in the
continuous form in the case of condition. Is this possible?

juvi
 
E

Evi

Conditional formatting won't change the contents of the textbox. That's not
formatting, that's data.
You can do this with vba however.
A practical application would be if the user chooses a particular product in
a form and you want to put the price that is normally charged for this
product into the Price field - the user then has the option of changing this
amount if he wants to give the customer a discount or to totally rip him
off.

You would use the After Update Event of the text box which causes it all to
happen (more details available if required)

A typical code would look (in essence) like this - we'll call the text
box/field Product.

If Me.Product = "Pears" then
'the user has typed pears into the Product field
Me.ProductDescription = Fruit
'the ProductDescription field will now have the word Fruit appear in it
Me.Price = £2
'£2 appears in the Price field
End If
 
J

juvi

the sample code doesn't work for me. now I added an SQL UPDATE for the
"wrong" items to be corrected - so this edited my DATA. but it is really
unconfortable that there is no possiblity to add some kind of conditions for
alternate text

thx
 
J

juvi

This would be exactly what I am looking for but I get a syntax error trying
to set.
these are my names
-----------------------
column-name: ME
textbox-name: tbME

I tried the following:

=IIf(ME = "ST", "PC", ME) and tried also =IIf(tbME = "ST", "PC", tbME)

but I get syntac error.

Marshall Barton said:
An Update query is a good way to permantly change the data.

If you only want to display one thing when the value of a
field is something else, you can use a text box expression
(VBA code won't do it on a continuous form):

=IIf(field = "ST", "PC", field)

but that text box will not be updateable.
--
Marsh
MVP [MS Access]

the sample code doesn't work for me. now I added an SQL UPDATE for the
"wrong" items to be corrected - so this edited my DATA. but it is really
unconfortable that there is no possiblity to add some kind of conditions for
alternate text
 
M

Marshall Barton

An Update query is a good way to permantly change the data.

If you only want to display one thing when the value of a
field is something else, you can use a text box expression
(VBA code won't do it on a continuous form):

=IIf(field = "ST", "PC", field)

but that text box will not be updateable.
 
M

Marshall Barton

juvi said:
This would be exactly what I am looking for but I get a syntax error trying
to set.
these are my names
-----------------------
column-name: ME
textbox-name: tbME

I tried the following:

=IIf(ME = "ST", "PC", ME) and tried also =IIf(tbME = "ST", "PC", tbME)

but I get syntac error.


Neither of those should get a syntax error. The second one
will return #Error because a text box expression can not
refer to itself.

Me is a reserved word in a VBA class module, bur not in a
text box control source expression, so that should cause a
problem here.

Are you sure you put that expression in the text box's
ControlSource property?

Are you sure that the ME field in the table really contains
ST? (e.g. If the table field is a lookup field, it could
really be a number.)
 

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