Show code meaning rather than code value

  • Thread starter Thread starter oldblindpew
  • Start date Start date
O

oldblindpew

I have a text box in a form that is displaying (as it should) the value of a
code that is stored in the bound field (hope I'm saying this right). I want
to display the code's meaning rather than its value.

I know a combo box would do it, and I'll use one if I have to, but I only
want to display the meaning, whereas a combo box is for picking a value.

Thanks,
OldBlindPew
 
Not sure how you're using the term "meaning"...

Are you saying you have a table somewhere that has a couple of fields, a
code and a "meaning" (is that the same as a title, or description or ...)?
And that you want to see that second part instead of the code?

Then yes, a combobox can do that quite easily.

First build a query that returns both code and "...". Then base your
combobox on that query.

In the design view, highlight the combobox, and set 2 columns, and set the
width of the first column (i.e., the code) to 0 (zero).

Now when you use the combobox, the code is what the combobox is storing in
the underlying field, but the "..." is what it is displaying in the form.

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
I have a text box in a form that is displaying (as it should) the value of a
code that is stored in the bound field (hope I'm saying this right). I want
to display the code's meaning rather than its value.

I know a combo box would do it, and I'll use one if I have to, but I only
want to display the meaning, whereas a combo box is for picking a value.

It *can be used* for picking a value, but it doesn't force you to do so. In
fact if you set its Enabled property to No, Locked to Yes, it will display the
text value even though it's bound to the numeric value, but it will not let
the user affect either.
 
What I'm wishing for is that the down arrow portion of the Combo Box would
disappear when the control is locked. It's just an aesthetic matter of not
wanting to show the user a non-functional control, and I think this would be
reasonable for the control to operate this way. Barring this, I would like
to use a Text Box, except I want to display the code's meaning from the
lookup table, rather than the code itself which is stored in the child table.
I suppose to do this I would have to join the lookup table to the child
table in my query, so my form would have access to that field?

I did not understand your suggestion about the Enabled and Locked
properties. A Combo Box will display the first column from the RowSource
that has a non-zero width, regardless of what you do with the Enabled and
Locked properties.

Thanks,
Pew
 
Jeff, thanks for replying.

I have a lookup table with two fields: Code and Meaning. Sample values
would be "A" and "Active", respectively.

My child table has a field for the Code as a foreign key, but I want my
form's textbox to show Meaning rather than Code, e.g. "Active" rather than
"A". As stated previously, I know a Combo Box will do this, and I know how
to make it work, so this was not my question. My question is how to do it
with a Text Box.

My reason for wanting a Text Box is aesthetic. In my form, this control
will be display-only. I don't see any point in presenting a non-functional
Combo Box to the user. In fact, I think a locked Combo Box should change
appearance to look like a locked Text Box. If it's locked (read-only) why
should there even be a down arrow/selector button followed by a drop-down
pick list, which the user is not going to be able to use anyway?

Thanks,
Pew
 
I have a lookup table with two fields: Code and Meaning. Sample values
would be "A" and "Active", respectively.

My child table has a field for the Code as a foreign key, but I want my
form's textbox to show Meaning rather than Code, e.g. "Active" rather than
"A". As stated previously, I know a Combo Box will do this, and I know
how
to make it work, so this was not my question. My question is how to do it
with a Text Box.

Assuming the record source for the child table is MyQuery and that Code
field is FK, how about this:

Select Meaning from MyLookupTable where MyQuery.FK = MyLookupTable.Code

Store the query as MyQuery2 and use DLookup("Meaning","MyQuery2") as control
source for the text box.

Warning: Noob suggestion, based on advice given me in another thread for
analogous (but more complicated) situation. -Ron
 
Thanks, Ron. The answer probably lies along these lines. For a Combo Box,
one can just name the lookup table as the Row Source. A Text Box doesn't
have its own Row Source, but has to use the form's Record Source. (I
probably don't understand all this right, but this is how it looks to me at
this time).

I also mentioned locking the controls, but this isn't right either. When I
lock the control, no data can be enterered at all. I don't want to
completely prevent data entry, but I just don't want the user to accidentally
change anything.

Thanks again,
Pew
 
Thanks for reading and replying. I fear I've offended the gods as some of my
recent questions have met with silence.

When a new record is added via my form, some of the fields are populated
from other tables, and this is the data I wish to protect. The key question
is whether the Before Update event will interfere with the addition of the
new record and automatic population of certain of its fields. Should be easy
enough to try and see. I have not yet needed the different events other than
On Click.

In the past I've created a separate form for updating vs. adding. I'm
thinking one cannot simultaneously allow and disallow editing in the same
form. Perhaps this is why a traditional approach uses modes: Add, Delete,
Update, and Browse. Obviously I have more to learn.

Thanks Again,
Pew
 
Alternate reasons (other than offending the gods) ... (since the folks who
respond here are volunteering their time) ...

1) nobody's home
2) nobody knows
3) nobody's available ("busy helping other customers"...)

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
Dear self,

To use a Text Box to display the Code's Meaning from a separate Lookup
Table, just go to the Query Builder for the form's Record Source, click on
Show Table, and add the Lookup Table.

Next, create a link between the Lookup Table's Code field and the
corresponding field in the child table. This relationship is only used in
the query, and will not affect the relationships shown under Database Tools
/Relationships.

Next, add the Code and Meaning fields from the Lookup Table to your query,
(or just specify all fields, since there are only the two).

Finally, specify the Meaning field's name as your Control Source for the
Text Box in your form.

Best of Luck,
OldBlindPew
 
Back
Top