CombBox (1 Viewer)

TurboDieselOne

Registered User.
Local time
Today, 21:33
Joined
Jan 16, 2003
Messages
39
HELP! HELP! HELP
I Have a form with Bound combo boxes these are Related to other Tables so the dropdownlist gives the names in table "Companies" now the problem is when an name is typed in that is not in the list it does not add it to the bound list. the error message does not come up as this LimitToList is set to no. Now I know this shoud be set to Yes to call up the Not in list Event and then I should put in a macro or Event etc to add to the list then when I click on the dropdown again it appears on the list. Bit long winded explanation but Only way us Bookeepers know
 

Mile-O

Back once again...
Local time
Today, 21:33
Joined
Dec 10, 2002
Messages
11,316
:::Trying to figure out what it is exactly that you want:::

So, you want to add a new entry that is entered into the combobox to the specific table?
 

TurboDieselOne

Registered User.
Local time
Today, 21:33
Joined
Jan 16, 2003
Messages
39
I Have A form with Several List/combo boxes on.
The dropdowmns on each show what is in that paticular related table ie the companies one show the list from the table Companies. now if I type in a Name of a Company that is not in the list I want to Automaticaly add it to the table Companies so it will appear the next time I the name in on this form. I know I could open the Companies table add the name as A new record and then go back and open the Main input form but I would prefer, as there is a lot of stuff like this on the Main input form, to do this automaticly.
 

Mile-O

Back once again...
Local time
Today, 21:33
Joined
Dec 10, 2002
Messages
11,316
Set the combox's LimitToList property to Yes

And on the NotInList() event put this code:

Code:
Private Sub cboGuarantee_NotInList(NewData As String, Response As Integer)

    Response = MsgBox("The Company you have entered is not in this list." & vbCrLf & vbCrLf _
        & "Would you like to add it?", vbQuestion + vbYesNo, "Company")
    If Response = vbYes Then
        Dim rs As Recordset
        Set rs = CurrentDb.OpenRecordset("tblCompanies")
        With rs
            .AddNew
            .Fields("Company") = NewData
            .Update
        End With
        Response = acDataErrAdded
    Else
        Me.Undo
        Response = acDataErrContinue
    End If
    rs.Close
    
End Sub

Just remember to amend the object names to your own.
 
Last edited:

Users who are viewing this thread

Top Bottom