Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Surpress not in list msg in combo box

Status
Not open for further replies.

captphan

Programmer
Jan 24, 2007
42
I have created a combo box I wish to limit to list. If the user adds a value that is not in the list I am using NotInList Property to give the user the choice of adding the item or leaving the field blank.
Code:
Private Sub SupplyID_NotInList(NewData As String, Response As Integer)
        
On Error GoTo SupplyID_NotInList_Err

    Select Case MsgBox("This item is not in the list do you wish to add it?", vbYesNo Or vbQuestion Or vbSystemModal Or vbDefaultButton1, "ADD PO")
    
        Case vbYes
            DoCmd.OpenForm "AddItem", , , , , acDialog, oaADDONLY
            Me.SupplyID.Requery
        Case vbNo
            Me.SupplyID.Undo
            Me.SupplyID.Dropdown
'In addition to the above I have tried   
'          Me.SupplyID.Value = ""
'          Me.SupplyID.Value = Null



            
            
    End Select

SupplyID_NotInList_Exit:

    Exit Sub

SupplyID_NotInList_Err:
    Select Case Err.Number
        Case Else
            MsgBox Err.Number & " " & Err.DESCRIPTION & Chr(13) & "In Sub SupplyID_NotInList"
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO ErrorLog ( ErrNumber, ErrDescription, ErrFunction, ErrDateTime, ErrLine, ErrModule )SELECT " & Err.Number & "," & Chr(34) & Err.DESCRIPTION & Chr(34) & " , 'SupplyID_NotInList', # " & Now() & "#, " & Erl() & " , 'Form_AddReceiptFrm';"
            DoCmd.SetWarnings True
            Resume SupplyID_NotInList_Exit

    End Select

End Sub

However I still get a system generated error telling me the item is not in the list. How can I surpress this msg?
 
You need to use Response:

Code:
        Case vbYes
            DoCmd.OpenForm "AddItem", , , , , acDialog, oaADDONLY
            'Me.SupplyID.Requery
            Response=acDataErrAdded
        Case vbNo
            Me.SupplyID.Undo
            Me.SupplyID.Dropdown
            Response=acDataErrContinue
'In addition to the above I have tried   
'          Me.SupplyID.Value = ""
'          Me.SupplyID.Value = Null
 
I have tried this fix. I am now getting a new error.
The expression On Not In List you entered as the event propery setting produced the following error: There was a problem refrencing a proprty or method of the object.
Any followup thoughts?
 
Which line gives the error? I suspect it is this one:

Me.SupplyID.Dropdown
 
Thank you. The second issue resolved itself with out any changes. I simply restarted my PC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top