Results 1 to 8 of 8
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combo Text (A2k)

    I've seen cases wher developers put text in a combo as default, some thing like the following:-

    <<< Make A Selection >>>

    Can any-one tell me where to put this in properties to achieve this.

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

    Re: Combo Text (A2k)

    The easiest way is to stick a record with the text "<<< Make a Selection >>>" in the table that acts as Row Source, and to put a check in the code to ignore this item. Or you could create a dummy table with one record containing this text, and use a Union query that selects records from the "real" row source and the dummy table. This will cause less problems when you want to use the row source table for other purposes.

    If you want to add an item to the row source dynamically, you must use a callback function as Row Source Type. This is far from trivial.

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Text (A2k)

    Hans
    I didn't really want to have a dummy record of <<< ???????? >>> in the underlying table.

    I've done the following instead :

    On form load
    Me.Combo??? = "<<< Make A Selection >>>"

    Can you see any danger in this ?
    For the time being, it works !!

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

    Re: Combo Text (A2k)

    It will work if the combo box is bound to a text field. You still have to check whether the combo box contains a valid entry, otherwise you may end up with ""<<< Make A Selection >>>" in the destination table.
    It won't work if the combo box is bound to a numeric field.

  5. #5
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Text (A2k)

    Thanks again, I only need it for a couple of combo's which are bound to text.
    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  6. #6
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Text (A2k)

    When the form is loaded subsequent to information having been selected on a previous date will the previous selection get over written by the Me.Combo??? = "<<< Make A Selection >>>" code?

    Regards

    Graeme

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

    Re: Combo Text (A2k)

    Yes. If the combo box is bound to a field in the underlying table/query, that is a problem. Instead of using code (in the OnLoad or OnOpen event of the form, I presume), set the DefaultValue property of the combo box to "<<< Make A Selection >>>". That way, existing records will not be modified, but the combo box will initially display "<<< Make A Selection >>>" in new records.

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

    Re: Combo Text (A2k)

    The method I generally use is a union query as the rowsource, something like this:

    SELECT Customers.CustomerID, Customers.CompanyName
    FROM Customers
    UNION
    SELECT Null As CustomerID,"<All Customers>" As CompanyName
    FROM Customers AS C1
    ORDER BY CustomerID, CompanyName

    Of course, you have to use code to handle the "All Customers" selection, since the fake customerID that matches it doesn't exist in the table.
    Charlotte

Posting Permissions

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