Combo box question

  • Thread starter Thread starter Sean G.
  • Start date Start date
S

Sean G.

Hello, it's been a long time since I made a combo box and
i'm having a bit of a problem. I have a combo box that
when a value is selected it selects a record within the
form. This part works great, however, when I change the
record with the record selectors on the bottom of the
form, all fields change, except the combo box. The last
value I manually selected in the combo box stays there
until I manually change it to something else.

Any help would be greatly appreciated.

-Sean
 
Unless you write code to put a value into the combo box (I assume that the
combo box is unbound, as you're using it .. likely in the form's header ..
to navigate to a record), it will retain the last selected value. If you
want it to track with other navigation that you do, you'll need to use the
form's Current event to run code that writes the appropriate value into the
combo box based on the current record's value for that field.

But, do you really need to do this?
 
I use code like this:

Private Sub Form_Open(Cancel As Integer)
Me!Combo14 = Me!OrganizationID
Me!Combo14.SetFocus
End Sub

and

Private Sub Form_Current()
If Me!Combo14 <> Me!OrganizationID Then Me!Combo14 = Me!OrganizationID

That way when someone scrolls through records, the combo box always reflects
what they're looking at.

-Matt
 
I agree, Tom. I would never leave anything at all showing in an unbound
combobox whose purpose is navigation, and I clear it as soon as it has
done it's job, i.e. as part of the same procedure where it takes you to
the selected record. But I wouldn't set it to "", as you suggested, it
should be Null, e.g.
Me.MyCombo = Null
 
Back
Top