Results 1 to 8 of 8
  1. #1
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Warrington, Cheshire
    Posts
    355
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Select first item in combo box (Access 2003)

    In a forms on activate event I'd like a combo box to have the first item in the list selected.
    Having read the help files and books they are saying that this is not possible (selected being read only) and that for an item to be automatically selected the items must be in alist box so I can state myList.Selected(0) = true

    Has anyone had success with making a combo box select the first item in the list?
    TIA
    Alan
    Cheshire

    Tia

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

    Re: Select first item in combo box (Access 2003)

    You can set the Default Value property of the combo box to [ComboBoxName].[ItemData](0) with the actual name of the combo box substituted.

  3. #3
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Warrington, Cheshire
    Posts
    355
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Select first item in combo box (Access 2003)

    Once again many thanks HansV.
    The setting of the default value didn't appear to be taking effect when I was using it in the forms activate or on load events, but when I used it to pre-empt any of the forms events then it worked a treat.

    Cheers
    Alan
    Cheshire
    UK

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

    Re: Select first item in combo box (Access 2003)

    You can set it in design view, no code needed.

  5. #5
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Warrington, Cheshire
    Posts
    355
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Select first item in combo box (Access 2003)

    The form with the combo box is a generic form which serves a couple of different user options.
    If the user selects "Report on Clients" then the combo box remains as normal
    If the user selects "Report on Areas" then I needed the combo box to have the first area selected as default.
    Don't ask me why, it's just the clients own request.

    Thanks
    Alan

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

    Re: Select first item in combo box (Access 2003)

    Your explanation isn't clear. Does this refer to a single combobox?.
    <hr> I needed the combo box to have the first area selected as default.<hr>
    If the "area" is in the combobox and you have already made a selection, then the request doesn't appear to make sense. And by the way, client/user requests need to be questioned closely. If you don't understand why they need it that way, you're liable to spend a great deal of time on something that could be accomplished quite simply by using a different approach.
    Charlotte

  7. #7
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Warrington, Cheshire
    Posts
    355
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Select first item in combo box (Access 2003)

    Charlotte,
    It's a single combo box on a generic form.

    The menu form permits the user to view a report based upon their initial choice.
    The choices are: (typically):
    by size - this is the engine size
    by hp - this is horse power at back wheel
    by colour - approx ten different colours
    by seating capacity - currently only monoposto available (single seat)

    upon choosing one of the above options a generic form is opened. the combo box is on this generic form.

    Depending on which selection the user makes, the row source for the combo on the generic form is sourced from different queries:-
    by size results in five rows in the combo box
    by hp results in eight rows in the combo box
    by colour results in ten rows in the combo box
    by seating capacity results in one row in the combo box

    Currently the client has no more than single seating capacity in production and for this reason if the user selected seating capacity then the client would want the combo box to have the single seat item pre-selected.
    The client does however want to present the user with the impression that single seater is not hard an fast limitation for the units.

    The current state of the db is for development and will have a limited lifespan but must at the same time serve as a canvas/design intent for future developments

    Hope that explains it, and currently with the advice from this board it appears to satisfy my original requirements.

    Thanks
    Alan

    ps clients request for form colour to change according to time of day was treated with the respect it deserved.

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

    Re: Select first item in combo box (Access 2003)

    In that case, you need either an If Else Endif or a Select Case structure in the Form_Load event code to handle the options. The popup form can handle it by testing to examine the name of the query assigned to its rowsource property and if that is the query in question, doing something like this:

    If Me.Combo1.RowSource = "ThatQuery" Then
    Me.Combo1 = Me.Combo1.ItemData(0)
    End If

    Where Combo1 is the name of the combobox, ThatQuery is the name of the query for seating capacity, and there are no column headers turned on in the combobox.
    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
  •