Results 1 to 5 of 5
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Populate Combo Box ? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Looking for best way to populate County and Town combo box codes

    I have a County lookup combo/table (one record for each county) and a Town lookup combo/table (one record for each town within the county)

    Operator Instructions if County and Town are known:

    1. Enter County Code, 01 through 57
    2. Select corerect Town from list, this will populate the Town Code

    The above works OK

    Operator Instructions if only Town is known:

    1. Enter County Code ?
    2. Start typing Town Name and select correct Town from list, this will populate County and Town Code

    The second procedure code seems to work, is there a better way to do this lookup and populate the Town Code
    Other than using Me.strTCVCode2 = strTCV - 1

    Thanks, John
    Attached Files Attached Files

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

    Re: Populate Combo Box ? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Can you explain what the purpose is of the line

    Me.strTCVCode2 = strTCV - 1

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Populate Combo Box ? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    That was the only way I could get the correct Town code in strTCVCode2

    In the attached demo if you type ? in Cty field this pops up list of Towns, if you type lewis and select Lewiston I want it to return Town code 03 to strTCVCode2

    With Me.strTCVCode2 = strTCV - 1 it returns 03 (Lewiston) which is what I want

    With Me.strTCVCode2 = strTCV it returns 04 (Lockport) which is incorrect, note 04 is the relative position in table starting a zero

    This gets back to my initial question, proper way to populate strTCV2 if only Town is known

    John

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

    Re: Populate Combo Box ? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    You set the BoundColumn property of strTCVCode2 to 0 in the code. This is not a good idea, it means that the value of the combo box is the (zero-based) index number of the selected item, instead of a value from the row source. There is no need to set this and related properties in code, you only need to set them once in design view. See attached version.
    Attached Files Attached Files

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Populate Combo Box ? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Thank you

Posting Permissions

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