View Full Version : Item NOT in ComboBox/Want to use MsgBox


briefpam
01-21-2002, 04:55 PM
I have a ComboBox in a form that calls on a table of "Vendors".

I want to be able to do the following.
1. I DON'T want the user to be able to
enter in any new data into the "Vendors" table using the ComboBox.
2. I want the user to be able to type in
letters so that they can quickly review
the list in the "Vendors" table. I have Limit to List set to Yes and Auto Expand set to Yes.
3. If what the user types doesn't match
any of the records in the list, I
want a MsgBox to pop up and ask the
user if they want to add a new Vendor.
4. If the user clicks on "Yes" a new form
appears allowing the user to enter in
all the data about a new vendor.

I have the main form and I have a seperate form for entering new vendor data. The program itself is working fine with the exception of this pesky combo box problem.

[This message has been edited by briefpam (edited 01-21-2002).]

[This message has been edited by briefpam (edited 01-21-2002).]

Jack Cowley
01-21-2002, 05:49 PM
In # 1 you say you don't want the user to be able to add a new record but in # 3 you say you do want the user to be able to add a new record. See this article to assist you in your quest....

http://support.microsoft.com/support/kb/a rticles/Q197/5/26.ASP?LN=EN-US&SD=gn&FR=0&qry=q197526&rnk=1&src=DHCS_MSPSS_gn_SRCH&SPR=ACC97 (http://support.microsoft.com/support/kb/articles/Q197/5/26.ASP?LN=EN-US&SD=gn&FR=0&qry=q197526&rnk=1&src=DHCS_MSPSS_gn_SRCH&SPR=ACC97)

[This message has been edited by Jack Cowley (edited 01-21-2002).]

briefpam
01-21-2002, 06:58 PM
I figured it out....

Private Sub VendorName_NotInList(NewData As String, Response As Integer)
Dim iAnswer As Integer
iAnswer = MsgBox("That vendor is not in the list, would you like to add a new vendor?", vbYesNo + vbQuestion)
If iAnswer = vbYes Then
DoCmd.OpenForm "Adding Vendor", acNormal, , , acAdd, acDialog
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If