Not In List

GGladu

New Member
Joined
Jul 13, 2014
Messages
12
I'm having a problem with this little app I created to print checks. I have a combo box with the limit to list set to yes. Sometimes I have a payee name that is only going to be used once so I don't want to add it to the list of payees but I can't get past the combobox. What am I doing wrong? Here's the code

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

Dim tblPayee As DAO.Database
Dim rsPayee As DAO.Recordset
Dim intResp As Integer
Dim strMsg As String


  ' Exit this subroutine if the combo box was cleared.
    If NewData = "" Then Exit Sub

    ' Confirm that the user wants to add the new customer.
    Msg = "'" & NewData & "' is not in the list." & vbCr & vbCr
    Msg = Msg & "Do you want to add it?"
    
    If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
        ' If the user chose not to add a customer, set the Response
        ' argument to suppress an error message and undo changes.
        Response = acDataErrContinue
        ' Display a customized message.
    Else
        ' If the user chose to add a new customer, open a recordset
        ' using the Customers table.
        Set tblPayee = OpenDatabase("PayeeList")
        Set rsPayee = tblPayee.OpenRecordset("tblPayee", dbOpenDynaset)
        ' Create a new record.
        rsPayee.AddNew
        rsPayee!strPayee = NewData
        rsPayee.Update
        ' Set Response argument to indicate that new data is being added.
        Response = acDataErrAdded
    End If
Exit_CustomerID_NotInList:
       Response = acDataErrContinue
       Exit Sub
Err_CustomerID_NotInList:
       ' An unexpected error occurred, display the normal error message.
       MsgBox Err.Description
       ' Set the Response argument to suppress an error message and undo
       ' changes.
       Response = acDataErrContinue
 End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

ranman256

Well-known Member
Joined
Jun 17, 2014
Messages
2,173
What do you want to do? You cant add items to a list that LIMIT TO LIST = YES.

You could have button to turn OFF the limit, then enter it into the list... LIMIT TO LIST = false
 

GGladu

New Member
Joined
Jul 13, 2014
Messages
12
Thanks! I didn't use a button. Here's what I did the reset the LimitToList back true when the next control got focus

Private Sub cmbPayeeList_NotInList(NewData As String, Response As Integer)
Response = acDataErrContinue
cmbPayeeList.LimitToList = False
cmbPayeeList_AfterUpdate

End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,651
Messages
5,838,579
Members
430,557
Latest member
MK15

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top