Hi John,
Yes, I do want the country description only to show in the combobox. But
I also want to be able to enter the 2 digit country code in the field,
if I do not use the combobox. I have gotten the combobox to display
both fields but I still have the problem of the description, not the 2
digit code, to be entered into the field when one is clicked on. My
reasoning is that there is no sense duplicating a 50 character field
when a 2 character field will do fine. I should be able to use another
lookup during reports, or whatever, to show the full country description
if I need to.
I will digest your suggestions and try again. I will post back later
with my results.
Maybe I am looking at this the wrong way. Right now, with the previous
SELECT statement I posted, it appears to insert the full country
description, but I do not get an error dialog about the field size being
too small, as I did before. Does this mean that Access is storing only
the 2 digit code but is showing me the full description? If this is
true then why can't I manually enter a 2 digit code without getting the
'not in list' error? As you can tell I know next to nothing and am
learning with this project. I have done relational databases design
since the DOS days but am new to Access.
Thanks for your help,
Charles
I thought you wanted only the description to show in the combobox.
If you want to show both, then clear the field width so that Access will
automatically show both columns in the drop-down mode. but only the
2DigCode
when the control is not in dropdown mode. If you only want the
2-digit country
code, then change your query to only select that, set number of
columns to 1.
As far as the problem with the brackets, I should have caught that.
Fieldnames
that don't start with a letter or that contain other than letters or
numbers
after the first character need [] around them.
Charles E Finkenbiner wrote:
Hi John,
You pointed me in the right direction but I do have a question. I
received an error message about: Syntax error (missing operator) in
query expression '2DigCode'. In order to fix this error I had to put
braces [] around the field names, no problem, at least I figured that
out. I changed number of columns to 2 and set column widths to 0" as
you suggested.
Now when I open the state table the combobox display is exactly like I
want. When I click on a country description I do not get a field size
too small error anymore (2DigCountryCode is set to field size 2). But,
the full country description is displayed, not the 2 digit code. Also,
if I manually enter the 2 digit country code I get an error telling me
that my entry is not in the list.
I want to be able to manually enter the 2 digit country code, if I know
it or select from the list. And I only want the 2 digit country code
displayed, not the full country description.
Am I misunderstanding something about Access?
Thanks for your help,
Charles
On 9/4/2005 3:08 PM, John Spencer (MVP) wrote:
Modify the query to show the country; cod
SELECT 2DigCode, Description from Countries ORDER BY Description
Leave the bound column as 1
Change number of columns to 2
Set Column width to 0 to hide the first column
That should do it, assuming that my memory for property names is
correct.
Charles E Finkenbiner wrote:
Hi All,
I have 2 tables, Countries and States.
Countries is setup like this:
2DigCode = Primary Key
3DigCode
Number
Description
States is setup like this:
Code = Primary Key
Description
2DigCountryCode
I am trying to use a lookup in field '2DigCountryCode' to be sure
that a
valid 2 digit country code is entered or selected. I want the
ComboBox
to show country descriptions but I want the 2DigCode inserted into
2DigCountryCode. I came up with this SQL query for the row source:
SELECT Description FROM Countries ORDER BY Countries.Description;
The bound column is set to number 1, because Countries.2DigCode is
column 1. But, when I select a country the description is entered
instead of the 2 digit country code. I have tried many things but I
have been unable to get it to do what I want.
Can someone please point out the error of my ways?
Thanks for any help,
Charles