Insert text in form based on numeric table value

I

IanC

Hi

I'm trying to modify an existing database, but I'm not too familiar with
Access. I apologise if this is one of those "everyone knows that" questions.

I've been able to create a group of tickboxes in a form and output the
selection to a numeric field in a table.

I now need to draw that data into another form, but not as a number. I need
specific text based on the number (2=Yes, 3=No).

Any pointers on how I can achieve this?

TIA
 
I

IanC

I think I'm getting somewhere, but I'm still having problems.

I've inserted a textbox and set the Control Source to
=IIf([Main service report]![Safe for use]=3,"YES","NO")
but this returns #Name?

If I just use [Main service report]![Safe for use], the result is 3 (the
value in the table).

Where am I going wrong?
 
J

John Spencer

Your control cannot have the same name as the field when you are using the
field in a calculation. Try changing the name of the control to txtSafeForUse
or even to SafeForUse.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
I

IanC

Hi John

Thanks for the response. Sorry, but I'm not sure I understand what you mean
by "control". The textbox name is Text84, the associated label is Label85.
I've changed the label caption to something very different (not that it
matched the table field, anyway), but it's still no better.

--
Ian
--
John Spencer said:
Your control cannot have the same name as the field when you are using the
field in a calculation. Try changing the name of the control to
txtSafeForUse or even to SafeForUse.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
I think I'm getting somewhere, but I'm still having problems.

I've inserted a textbox and set the Control Source to
=IIf([Main service report]![Safe for use]=3,"YES","NO")
but this returns #Name?

If I just use [Main service report]![Safe for use], the result is 3 (the
value in the table).

Where am I going wrong?
 
J

John Spencer

Ok, then if the textbox's name is text84 then you don't have the name problem
conflict.

A control is a label, textbox, line, combobox, etc. It is one of the objects
you can place on a form or a report.

You might try the following as the CONTROL source
=IIf([Safe for use]=3,"YES","NO")

If that fails, then check the list of fields and see if you have Safe For Use
in the list of fields. If not, then you need to change the form's record
source so Safe for use is an available field.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
I

IanC

Hi John

If I use Safe for Use as the control source (picked form the list of
fields), I get 3 returned, which is the value in the table. It's only when I
try to apply the IIf condition to it.

Any other thoughts?
--
Ian
--
John Spencer said:
Ok, then if the textbox's name is text84 then you don't have the name
problem conflict.

A control is a label, textbox, line, combobox, etc. It is one of the
objects you can place on a form or a report.

You might try the following as the CONTROL source
=IIf([Safe for use]=3,"YES","NO")

If that fails, then check the list of fields and see if you have Safe For
Use in the list of fields. If not, then you need to change the form's
record source so Safe for use is an available field.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
Hi John

Thanks for the response. Sorry, but I'm not sure I understand what you
mean by "control". The textbox name is Text84, the associated label is
Label85. I've changed the label caption to something very different (not
that it matched the table field, anyway), but it's still no better.
 
J

John Spencer

If **ANY** control on the form is not named Safe for Use,
and the field is available in the list of fields
and the control's source is as follows (including the equal sign)
=IIf([Safe for use]=3,"YES","NO")
then I am stumped.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
I

IanC

Hi John

I feel stupid, now! I was modifying an existing form which had previously
used "Safe for use" when it was a yes/no field. I'd forgotten this was still
on the form. I renamed the control for now and everything's working fine.

Sorry to have been so dim :-(

--
Ian
--
John Spencer said:
If **ANY** control on the form is not named Safe for Use,
and the field is available in the list of fields
and the control's source is as follows (including the equal sign)
=IIf([Safe for use]=3,"YES","NO")
then I am stumped.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
Hi John

If I use Safe for Use as the control source (picked form the list of
fields), I get 3 returned, which is the value in the table. It's only
when I try to apply the IIf condition to it.

Any other thoughts?
 

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