Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Jul 2003
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combo Box (Access2002)

    I have a form with a combo box in the Forms Header; when I open the form I want the Combo Box to display the first value from the record source. Currently the Combo Box is blank when the form opens,

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

    Re: Combo Box (Access2002)

    Do you mean the first value of the Row Source of the combo box? If so, set the default value of the combo box to

    [ComboBoxName].[ItemData](0)

    substituting the name of the combo box.

  3. #3
    2 Star Lounger
    Join Date
    May 2002
    Location
    Jerusalem, Israel
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Box (Access2002)

    Hans,

    I am trying to do a similar thing with a combo box in the detail view of a continuous form. The purpose of my combo box is to give the user a choice of standard text that we use in another field on the page, select the text which, using a macro, automatically places the text into the appropriate field. However, right now I am having difficulty trying to get it to display the default value after selecting an item from the list.

    Right now, after you select an item from the list, the combo box stays on that particular item. I want it to go back to the default item.

    I am using Access 2000.

    Any ideas?

    Thanks,

    JoeK

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

    Re: Combo Box (Access2002)

    If the combo box is bound to a field in the record source of the form, it'll display the value of the field. If it were reset to the default value, the field would be set to the default value, so you'd never be able to enter anything but the default value in the field.

    If the combo box is *not* bound to a field in the record source of the form, it will display the same value in all records of the continuous form. You could use code to reset it but I'm not sure that users would like that - it might be unsettling to see the value change back immediately after you select it.

  5. #5
    2 Star Lounger
    Join Date
    May 2002
    Location
    Jerusalem, Israel
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Box (Access2002)

    Hans,

    Thanks for your answer. My situation is the second one you mention - it is unbound.

    Is the code you mention a complicated thing to do? I wouldn't mind trying it out if it isn't too much trouble. If it is, don't worry about it, I'll make do with what I've got. It works fine as it is. I'm just trying to make it look better - as you say, the same value is displayed in all records of the continuous form, so having it revert to a default after it has been used in one record will make it look better in all the others, if you know what I mean.

    But as I said, the way I have it now is fine. This is just a "tweak".

    As always, much appreciated,

    JoeK

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

    Re: Combo Box (Access2002)

    You could try something like this:

    Private Sub MyCombo_AfterUpdate()
    ' Code to fill in other controls goes here
    ...
    ...
    ' Set default value
    Me.MyCombo = Me.MyCombo.ItemData(0)
    End Sub

    where MyCombo is the name of the combo box.

  7. #7
    2 Star Lounger
    Join Date
    May 2002
    Location
    Jerusalem, Israel
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Box (Access2002)

    Hans,

    Thanks for your prompt and very helpful reply. In this case, automatically reverting to the default item in the Combo Box is just what we needed. The users have said that they like it much better than having the previously selected item appear in the Combo Box throughout the continuous form.

    Much appreciated and best regards,

    JoeK

Posting Permissions

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