NotInList

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
 
A

alan fisher

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top