Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Microsoft: Access Forms FAQ

Combo Boxes

Combobox - Add New Item to List by KenReay
Posted: 9 Oct 03

Adding new entries to a Combo Box based on a query or table.

Say you have a combo box with entries taken from a table or query, where you wish to limit the user to choosing entries from the list, but allow the user the option to add new entries to the list.


the combo box to be added to is called cboLastName.

The form to Maintain the table (or query) on which cboLastName is based is called frmPeople.

For cboLastName,

LimitToList : Yes

In the NotInList Event put code so:

Private Sub cboLastName_NotInList(NewData As String, Response As Integer)
    If MsgBox("Add to List?", vbYesNo, "Warning") = vbYes Then
        DoCmd.OpenForm "frmPeople", acNormal, , , acFormAdd, acDialog, NewData
        Response = acDataErrAdded
    End If
End Sub

Ie ask the user if they want to make a new entry

If yes, open the appropriate form, as a modal form, in Add record mode, and pass the entered data (NewData) to the form frmPeople

On returning from the form frmPeople, inform combo box that the data was added.

For the Form frmPeople

In the Form Open Event extract the data passes using the OpenArgs property:

Private Sub Form_Open(Cancel As Integer)
    If IsNull(Me.OpenArgs) Then
        Lastname = Me.OpenArgs
    End If
End Sub

Ie Extract the passed data from the æSendingÆ form

Make a new record (using standard wizard code as shown below), and populate the new data

Private Sub cmdAddNew_Click()
On Error GoTo Err_cmdAddNew_Click

    DoCmd.GoToRecord , , acNewRec

    Exit Sub

    MsgBox Err.Description
    Resume Exit_cmdAddNew_Click
End Sub

Back to Microsoft: Access Forms FAQ Index
Back to Microsoft: Access Forms Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close