[AccessD] Not-In-List Popup Form question

Bob Gajewski rbgajewski at adelphia.net
Wed May 21 22:39:30 CDT 2008


Hi Folks - me again  :(

I am trying to figure out how to handle NotInList code to popup a form for
adding the new record; allowing the addition of only 1 record; then closing
the popup and returning the added value.

I have an equipment table, and one of the fields is for the manufacturer. My
code below opens the form, allows for the addition of any number of entries,
then when manually closed it leaves the original value that fired the NIL
event. I can live with the manual popup form close, but I really want to
only allow a single record addition. 

Any suggestions are much appreciated!

Regards,
Bob Gajewski


============================================================================
=========

Private Sub EquipmentManufacturerID_NotInList(NewData As String, Response As
Integer)
Dim db As Database, rs As Recordset
Dim strMsg As String
strMsg = "'" & NewData & "' is not in the Manufacturers table. "
strMsg = strMsg & "Would you like to add it?"
If vbNo = MsgBox(strMsg, vbYesNo + vbQuestion, "Add Manufacturer") Then
    Response = acDataErrDisplay
Else
    On Error Resume Next
    DoCmd.OpenForm "frmManufacturers", acNormal, , , acFormAdd, acDialog
    DoCmd.Save
    If Err Then
        MsgBox "An error occurred. Please Try Again."
        Response = acDataErrContinue
    Else
        Response = acDataErrAdded
        LastUpdated = Date
    End If
    Me!EquipmentManufacturerID.Requery
End If
strMsg = ""
End Sub





More information about the AccessD mailing list