i have a form where users input a lender name in and they
choose the lender by clicking on a drop down combo box.
if the lender is not there is there a way the users can
type i a new lender? like adding a new lender to the
drop down list
The combo box's "NotInList" event procedure would be the way to go. You can use
the following method (it requires that you have, or set, a reference to the DAO
Object Library appropriate for your version of Access).
See
http://support.microsoft.com/default.aspx?kbid=197110.
'*****EXAMPLE START
Private Sub cboColors_NotInList(NewData As String, _
Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
'Open recordset containing no existing rows by
'filtering to non-existent value (faster)
strSQL = "SELECT Color " & _
"FROM tblColorsLkp " & _
"WHERE ColorID=0"
'Prompt user to add or not
If MsgBox("""" & NewData & """ is not in the list. " _
& "Would you like to add it?" _
, vbYesNo + vbQuestion, "New Value") = vbYes Then
'User said "Yes"
'Open recordset and add new value
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
With rs
.AddNew
!Color = NewData
.Update
End With
'Tell Access that the value has been added
' and to requery combo box
Response = acDataErrAdded
Else 'User said "No"
'Tell Access to show default error message
Response = acDataErrDisplay
End If
End Sub
'*****EXAMPLE END
If you need further assistance with this, just post back with any questions you
might have.