Arthur Fuller
artful at rogers.com
Sun Nov 28 12:29:50 CST 2004
Here is a function that might prove more useful. It is mostly compatible but has the advantage that you can use it everywhere, rather than tying it to one specific combo-box. It lets you specify the form to pop up, in case the add-to-list is complext (i.e. needs several required fields). <code> Public Function aaNotInList _ ( _ NewData As String, _ Response As Integer, _ strForm As String, _ strTerm As String _ ) 'This function works just like the standard NotInList Sub, 'but adds two new parameters so you can specify the name of the 'form to pop up, and the generic name of the object (i.e., customer, agent, etc.) 'Note: this function requires the IsLoaded function, for which there are many sources. Dim mbrResponse As VbMsgBoxResult Dim strMsg As String strMsg = NewData & _ " is not on file. " & _ "Add a new " & strTerm & "?" mbrResponse = MsgBox(strMsg, _ vbYesNo + vbQuestion, "Unknown " & strTerm) Select Case mbrResponse Case vbYes DoCmd.OpenForm strForm, _ DataMode:=acFormAdd, _ WIndowMode:=acDialog, _ OpenArgs:=NewData ' Stop here and wait until the form ' goes away. If IsLoaded(strForm) Then Response = acDataErrAdded Debug.Print "Closing " & strForm DoCmd.Close acForm, strForm Else Response = acDataErrContinue End If Case vbNo Response = acDataErrContinue End Select End Function </code> Arthur Joe Hecht wrote: >I am copying and will attribute the following code from KG et al ADH > > > >Private Sub cboEmpName_NotInList(newdata As String, Response As Integer) > >Dim strMsg As String > >Dim rst As Recordset > >Dim db As Database > > > > > > strMsg = "'"& NewData &"'" is not in the list. " > > strMsg = strMsg & "Would you like to add them?" > > > >Does any one know why the first strMsg line is evaluating to to red ? > > > >Thanks > > > >JOE HECHT > >LOS ANGELES CA > >jmhla at earthlink.net > > > > > -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.289 / Virus Database: 265.4.3 - Release Date: 11/26/2004