Results 1 to 10 of 10
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    Crestview Hills, Kentucky, USA
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combo Boxes (Access 2002)

    Combo Boxes continue to give me fits.

    I have a form with a field (from the table) names "Country." I have a table with 2 fields -- Code and Country.

    I have tried to create a combo box on the form. The drop-down list has the code in the first column and the name of the country in the second column. I want to type or select a code, and have the country name (not the code) entered into the "Country" field.

    Combo Box Properties:
    Control Source = Country
    Row Source = SELECT [CountryList Query].Code, [CountryList Query].Description FROM [CountryList Query];
    (CountryList Query is made from Country Table, Description is the name of the country)
    Column Count = 2
    Bound Column = 2

    What am I doing wrong? Access places the code in the field.

    Thanks,
    Craig.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Combo Boxes (Access 2002)

    Why do you want to store the name of the country in a field? It is much more efficient to store the code. You can always look up the name in a query.

  3. #3
    Star Lounger
    Join Date
    Jan 2001
    Location
    Crestview Hills, Kentucky, USA
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Boxes (Access 2002)

    Hans:

    Thank you for the quick response. Unfortunately the boss wants the name of the country. I have the same problem with states -- I have a list of State Codes & State Names. The boss wants to type the code and have the name of the state placed in the table field.

    The country and state combo boxes are driving me nuts!

    Thanks,
    Craig.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Combo Boxes (Access 2002)

    <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>

    Are you sure that the code is actually stored in the table? If the first column of the combo box has non-zero width, that column will be displayed in the text box part of the combo box, even though Bound Column = 2 causes the second column to be stored in the Control Source field.

  5. #5
    Star Lounger
    Join Date
    Jan 2001
    Location
    Crestview Hills, Kentucky, USA
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Boxes (Access 2002)

    Hans:

    Yes, column 1 of the table has a list of codes, column 2 has the country names. Example US -- Unites States. Both columns show up in the combo box drop-down list. We want to type "US" and have "United States" entered in the Country field on the form and the table from which the form is derived.

    Even though the Bound Column = 2, the value from column 1 is stored in the Country field.

    Thanks again,
    Craig.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Combo Boxes (Access 2002)

    That is strange - I did a small test before I posted my previous reply, and if Bound Column = 2, the value from the second column is stored, as expected and intended. Could you post a stripped down version of your database?
    <UL><LI>Make a copy of the database and work with that.
    <LI>Remove all database objects (tables, queries, forms, reports, macros and modules) that are not relevant to the problem.
    <LI>In the remaining table(s), remove most records - leave only the minimum number necessary to demonstrate the problem.
    <LI>Remove or modify data of a confidential nature.
    <LI>Do a compact and repair (Tools/Database Utilities).
    <LI>Make a zip file containing the database; it should be below 100KB.
    <LI>If you have difficulties getting the zip file below 100 KB, save the database in Access 97 format and then zip it.
    <LI>Attach the zip file to a reply.[/list]That would enable Loungers to look at the problem directly.

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Combo Boxes (Access 2002)

    Are you saying that if you open the table itself, you see the country code in that field rather than the country name? Do you by any chance have a combobox lookup on the field in the table? Also, you do realize that a combobox bound to other than the first column will still show the first visible column after you make a selection, right?
    Charlotte

  8. #8
    Star Lounger
    Join Date
    Jan 2001
    Location
    Crestview Hills, Kentucky, USA
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Boxes (Access 2002)

    Charlotte and Hans:

    I see! Access IS actually storing the country name in the table, but displays the country code in the form. The more I use Access the more mystified I become!

    Can Access be forced to display the country name in the Form with the combo box?

    Thanks,
    Craig.

  9. #9
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Combo Boxes (Access 2002)

    If you're storing the country name, why bother showing the country code in the first place?
    Charlotte

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Combo Boxes (Access 2002)

    Try the following:
    - Put a text box over the combo box, leaving the dropdown arrow free.
    - Set the Control Source of the text box to Country.
    - Make sure that neither the combo box nor the text box is named Country; for example, name the combo box cbxCountry and the text box txtCountry.
    - Put the following code in the On Enter event of the text box:

    Private Sub txtCountry_Enter()
    Me.cbxCountry.SetFocus
    End Sub

    (thanks to Charlotte for this tip!)

    When the user clicks the text box/combo box, the country code will be displayed, but once the user clicks in another control, the country name will be shown.

    (Access is not mystifying at all in this case; you - or your boss - want things the other way round from what is customary)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •