Results 1 to 9 of 9
  1. #1
    Join Date
    Apr 2007
    Location
    Stalybridge, Manchester
    Posts
    273

    Unanswered: Combo Box values

    Hi, on a combo Box how can I select a numeric value and then it show a description?

    eg 1 = England
    2 = USA

    Thanks,
    Jez

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Combo boxes can either be bound or unbound (ie they display a value based on the underlying column for that record)
    they can also use values from another table
    you can limit them to the values already in existence or allow the user to add new values as thy go along

    from what you are asking Id expect the record source of the combo box to be a table
    so when designing you combo/list box, using the wizard you specify which table to use, and as part of that design you tell the desinger that you only want to display the country name and hide the index number (which is the default behaviour when using the wizard to design a combo/list box.

    you then bind the value of the box to a column in your database. the box control automatically knows to display the name to the user, but use the value to store data.

    if you provide a series of values (an alternative to drawing the results from a table) then you would specify the values as per the wizard or as a semi colon delimited list "1;United Kingdom;3;USA;99999999;France;"

    In design terms drawing values from a table is the preferred method as it allows your users to add whatever other categories they see fit in an appropriate table/form and then use those values in any other forms in list/combo boxes. it requires no further intervention from you, the developer.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Apr 2007
    Location
    Stalybridge, Manchester
    Posts
    273
    Healdem,
    I'm not sure I understand what you mean...

    I want the user to input the numeric input eg 1 0r 2 etc and once that is input then it display the description of that input.

    These are held in a table.

    Jez

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    why would you want your users to type in 1 or 2 or whatever numeric value, when (I'm guessing) you users will be more familiar with the Country Name rather than an arbitary number you have allocated to a country. ANother eeason to use the name rather than the index is that you can abstract the data as required. eg if you were requesting country some people see themselves as British, English, Scots or Welsh. Going down that route you can let them say whatever country they like, but actually resolve it back to whatever mechanism you want to store. it also allows you to use alternatives (eg some people may say America or USA, or United States of America or whateevr.. they can all resolve back to the same actual country number

    the point of using a list or combo box is to allow the users to select from a list that includes the relevant options OR a mechanism of abstracting the data from the presentation. you users shouldn't need to know that country 1 is the UK, 2 is the US, all they really need

    however if you want to type in an index number and display that countries value then one way is to have an unbound control. in that controls on exit,on change events place some code which sets the value of the combo/list box to that value. the box will /should display the correct country. the downside is that your uses may type in an invalid number (something which a list/combo box limited to list will not permit) you then have a potential data problem as the box will have invalid data. it may be that when you try to assign the value of the text box number to the list/combo box that the list/combo will throw an error.. if so you need to trap that error and handle it appropriately
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Apr 2007
    Location
    Stalybridge, Manchester
    Posts
    273
    I need to have the user inputting the numeric input as the paper forms that they are inputting from are all shown as numeric value but when the database is input I want to show as a description.

    Jez

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    in which case consider showing 2 columns in your lit box.. the first one being the number, the second being the name.

    assuming you have already set up the list box to read the from the country table then adjust the colum widths to (say) 0.75cm;4.5cm. you may need to adjust the number of columns shown.. cant guarantee that as Im not on a office enabled workstation at present
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Apr 2007
    Location
    Stalybridge, Manchester
    Posts
    273
    Excellent thanks that works, but once I choose an option in the list is selected it always shows the numeric value afterwards, how can i just see the description and not the number?

    Jez

  8. #8
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I suppose you could do some trickery with the on focus/on lost focus events, such as setting the columns to 0.5cm; 4.5cm on focus and 0;5cm on lost focus

    but why would you want to do that?
    is it a customer requirement? or is its something you'd like to do, because it looks pretty?
    I'd rather be riding on the Tiger 800 or the Norton

  9. #9
    Join Date
    Apr 2007
    Location
    Stalybridge, Manchester
    Posts
    273
    Unfortunately its a customer requirment, as I was happy with them inputting in as a text box.
    How would I do this trickery with the on and lost focus?

    I am realitively new to access and picking things up daily. reason for all my threads

    Jez

Posting Permissions

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