NotInList

  • Thread starter Thread starter qc
  • Start date Start date
Q

qc

Hello,
I am a rookie when it comes to Access and I hope someone can help me with
the following:
I want to be able to update the "Customers" table without exiting the form
that is using a list box to look-up values from "Customers" table. I heard
of the NotInList event, but don't know where to start. Any suggestions?
Thanks in advance for your help.
SD
 
You need to add the following code (edited to suit your
naming convention) to the Not in List event for the list
box. Don't forget to set the Limit to list property to
yes. email me if you need more help.


Dim strMsg As String
Dim rst As DAO.Recordset
Dim db As DAO.Database

strMsg = "'" & NewData & "'" & " has not been used
before. "
strMsg = strMsg & " Would you like it to be added?"

If vbNo = MsgBox(strMsg, vbYesNo +
vbQuestion, "Unknown Customer") Then
Response = acDataErrDisplay
Else
Set db = CurrentDb
Set rst = db.OpenRecordset("CustomersTable")
rst.AddNew
rst("Customer") = NewData
rst.Update
Response = acDataErrAdded
rst.Close
End If
 
Back
Top