Combo Box Help...

Meking

New member
Local time
Today, 12:38
Joined
Aug 10, 2007
Messages
8
I have a form that is used to order office products. I would like the person who is entering the order to be able to type directly into the field, and once the item has been entered, it becomes an item listed in the combo box from that point on.

Currently the user needs to go to a seperate form to add an item to the combo box. I would like to make it one quick step.

Hopefully this makes sense.... Thanks for the help.
 
Thanks, that works great.

Im sure I can figure this out, but is there a way to add what ever was typed into the field, to go directly into the look up table?
 
This may be more useful, easier to understand, it gives the sql to insert into the table

Code:
Private Sub cboCity_NotInList(NewData As String, Response As Integer)
    
    On Error GoTo cboCity_NotInList_Err
    
    Dim intAnswer As Integer
    Dim strSQL As String
    Dim strMess As String, strStyle As String, strTitle As String
    
    strMess = "The job title " & Chr(34) & NewData
    strMess = strMess & Chr(34) & " is not currently listed." & vbCrLf
    strMess = strMess & "Would you like to add it to the list now?"
    
    strStyle = vbQuestion + vbYesNo
    
    strTitle = "Add new data?"
    
    intAnswer = MsgBox(strMess, strStyle, strTitle)
    
    If intAnswer = vbYes Then
        strSQL = "INSERT INTO tblCity([City]) VALUES ('" & NewData & "');"
        DoCmd.SetWarnings False
        DoCmd.RunSQL strSQL
        DoCmd.SetWarnings True
        MsgBox "The new job title has been added to the list." _
            , vbInformation, "Acme Oil and Gas"
        Response = acDataErrAdded
    Else
        MsgBox "Please choose a job title from the list." _
            , vbInformation, "Acme Oil and Gas"
        Response = acDataErrContinue
    End If
cboCity_NotInList_Exit:
    Exit Sub
cboCity_NotInList_Err:
    MsgBox Err.Description, vbCritical, "Error"
    Resume cboCity_NotInList_Exit
End Sub
 

Users who are viewing this thread

Back
Top Bottom