Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Page History: HandleNotInList Subroutine - Access

Compare Page Revisions



« Older Revision - Back to Page History - Current Revision


Page Revision: Wed, Oct 22, 2008, 3:28 PM


The following VBA code is useful for handling the ComboBox_NotInList event handler.

Sub HandleNotInList(newData As String, response As Integer, entityName As _
String, targetTable As String, targetField As String)
    
    If vbYes = MsgBox("Add '" & newData & "' as a new " & entityName & "?", _
    vbYesNo + vbQuestion + vbDefaultButton1) Then
    
        Application.CurrentDb.Execute "INSERT INTO [" & targetTable & "] ([" & _
               targetField & "]) VALUES ('" & Replace$(newData, "'", "''") & "');"
                            
        response = acDataErrAdded
    
    Else
        
        response = acDataErrContinue
    
    End If

End Sub

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.