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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

on not in list error

Status
Not open for further replies.

NightZEN

Programmer
Apr 29, 2003
142
US
I am having trouble with the following code:

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

    Dim intNew As Integer
    Dim strQry As String
    Dim stLinkCriteria As String

   
    
    intNew = MsgBox("The IR Root-Cause code '" & NewData & "' is not in the list. Would you like to add it?", vbYesNo)
    If intNew = vbYes Then
        strQry = "INSERT INTO tbl_ir_codes ( irc_code ) " _
                & "SELECT '" & NewData & "' AS Expr1;"
        
        DoCmd.SetWarnings (False)
        DoCmd.RunSQL strQry
        DoCmd.SetWarnings (True)
        
        
        Response = acDataErrAdded
        
    Else
        MsgBox ("The name you entered isn't in the list.")
        DoCmd.RunCommand acCmdUndo
        Response = acDataErrContinue
    End If
End Sub

It works as is, but when I put "me.ir_code.Requery" after "Response = acDataErrAdded" to set the value to the NewData I get the following error: "Run Time error '2118': You must save the current field before you run the requery action."

I just want the added text to appear after you click Yes to add it.

Thanks
 
I think you must undo, requery and then fill the control in.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top