How to make one option of a listbox add data to a new field

105 views Asked by At

I have a listbox in a Microsoft Access 2010 form. The listbox has several options and the last one is 'Other'.

When someone selects 'Other' I want the user to be able to type in their data and have it push that data into a different field. Note, I do not want the user to add new options to the listbox.

For instance if the list box was a field called 'Browsers' and my choices were: Internet Explorer, Firefox, Chrome, Other. When the person selects Other, I want them to be able to type in 'Safari' in a field in my database called 'Browsers_Other'.

I cannot seem to figure this out. It looks to be related to similar to 'Cascading Listbox' but I think it is different. I am wondering if I need to have the action open up a sub-form...

1

There are 1 answers

4
HansUp On BEST ANSWER

You can add a text box bound to the Browsers_Other field. I called my text box txtOther.

Then from the list box's After Update event, enable the text box when the list box selection is "Other". When the list box selection is anything else, disable the text box and set its value to Null.

Private Sub lstBrowser_AfterUpdate()
    If Me.lstBrowser.value = "Other" Then
        Me.txtOther.Enabled = True
        Me.txtOther.SetFocus
    Else
        Me.cmdSave.SetFocus
        Me.txtOther.Enabled = False
        Me.txtOther.value = Null
    End If
End Sub

enter image description here

enter image description here