Michael
Michael

Reputation: 3239

Selecting different item in multi column combobox doesn't update the value shown - Access 2016

I have a combobox with 3 columns. I have a Change() event listener on that combobox that fires every time I click a new item. The very first time I click that item, it retrieves the values and updates other textboxes accordingly like so:

Private Sub cb1_Change()
    If cb1.Value = "" Or IsNull(cb1.Value) Then
        tb1.Value = ""
        tb2.Value = ""
        tb3.Value = ""
    Else
        tb1.Value = cb1.Column(0)
        tb2.Value = cb1.Column(1)
        tb3.Value = cb1.Column(2)
    End If
End Sub

Lets say I select the item that contains this information: 1, 1, 2017. It would go and populate tb1, tb2, and tb3 with 1, 1, 2017 respectively. If I click a different item, say 2, 2, 2018, The change event fires, and goes into the Else statement. However, cb1.Column(0), cb1.Column(1), cb1.Column(2), still return the values 1, 1, 2017 and not 2, 2, 2018.

Why are these values not updating on every subsequent click?

Upvotes: 0

Views: 90

Answers (1)

Minty
Minty

Reputation: 1626

Here goes ;-)

The change event fires for every keystroke, but the data isn't saved at that point so the underlying column data isn't updated to reflect the unsaved changed displayed value.

The AfterUpdate event only fires after the data is saved (dirtied is probably the correct technical term) and hence the column data you are using is also now updated reflecting the saved value.

Upvotes: 1

Related Questions