Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2001
    Posts
    175

    Unanswered: Updating a combo box

    Hi,

    I have a form with a combo box field called clientcombo. The user can either select a client code or type one in. If the user types in a client code say NCLIENT and the client does not exist, a message comes up asking if you want to enter a new client. If the user select 'yes' he is taken to another form to enter the client information.

    All of the above works fine. After entering the client information the user is returned to the combo box to select the client he just entered. The problem is that the client is not showing up in the combo box list.

    How do I get the new client to show up in the combo box list for the user to select (because I have code on the after update event) and on what event do I put the code?

    Help please!

  2. #2
    Join Date
    Jun 2002
    Posts
    59
    I have used this Combo Box in many situations and it works like you outlined BUT it DOES add the new entry to the list in the Combo Box.

    1. Have you set the Property "Limit to List" to YES in the Combo Box Property sheet? The default is No.

    2. Here is the code I use.
    Explanation: LOCATION Is the street name in the Combop Box. I use or add Street Names in the Box called LOCATION. This can be changed in the places in the code to the required name.
    I Dim NewStreet as integer. You can use New????? as you wish
    I open a Form "OPen New street" which you seem to be doing also.

    Private Sub LOCATION_NotInList(NewData As String, Response As Integer)
    Dim NewStreet As Integer, Title As String, MsgDialog As Integer
    Dim MsgText As String
    Const MB_YESNO = 4
    Const MB_ICONEXCLAMATION = 48
    Const MB_DEFBUTTON1 = 0, IDYES = 6, IDNO = 7
    Const CLR_WHITE = 16777215
    Const NORMAL = 1
    If IsNull([LOCATION]) Then
    Title = "Street not in List"
    MsgDialog = MB_YESNO + MB_ICONEXCLAMATION + MB_DEFBUTTON1
    NewStreet = MsgBox("Do you wish to add a new street name?", MsgDialog, Title)
    If NewStreet = IDYES Then
    DoCmd.DoMenuItem A_FORMBAR, A_EDIT, A_UNDOFIELD, , A_MENU_VER20
    [LOCATION].Enabled = True
    DoCmd.RunMacro "OPEN NEW STREET"
    [LOCATION] = NewData
    Forms![STREET]![STREET] = [LOCATION]
    Response = DATA_ERRCONTINUE
    End If
    If NewStreet = IDNO Then
    DoCmd.DoMenuItem A_FORMBAR, A_EDIT, A_UNDOFIELD, , A_MENU_VER20
    MsgBox "ESC"
    End If
    Response = Date_ERRCONTINUE
    End If
    End Sub

    I hope this helps. If not get back to me.
    Frank

  3. #3
    Join Date
    Sep 2001
    Posts
    175
    Thanks - will give it a try.....

Posting Permissions

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