By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 897 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Combobox Not In List Event

P: n/a
This has probably been posted before but i've searched and couldn't
find the answer I'm looking for (or just couldn't understand it) but
here's what i'm trying to do:

i have a table (tbl_participants). One field on this table is
R_Category which looks up the table tbl_Category (field "Category").

I have created a form (frm_Participants) based on tbl_Participants.
This form has a combobox on it for the R_Category field. I have placed
the following code on the On Not In List Event for R_Category:

*****Code Start*****
Private Sub R_Category_NotInList(NewData As String, Response As

Dim rstCat As ADODB.Recordset
Dim strAnswer As String

strAnswer = MsgBox("'" & NewData & "' is not in list of Categories"
& vbNewLine & vbNewLine & "Do you want to add it?", _
vbQuestion + vbYesNo, "Category Not in List!")

If strAnswer = vbYes Then
Set rstCat = New ADODB.Recordset
rstCat.Open "tbl_Category", CurrentProject.Connection,
adOpenStatic, adLockOptimistic

rstCat!Category = NewData
MsgBox "'" & NewData & "' added to list of Categories",
vbOKOnly + vbInformation, "Category Added!"
MsgBox "'" & NewData & "' has not been added to list of
Categories!", vbInformation + vbOKOnly, "Process Cancelled!"
IsNull (Me.R_Category)
End If

Set rstCat = Nothing
Response = acDataErrAdded

End Sub
******Code End*******

When i try to add a new category to the list, after my custom message
boxes appear, it still comes up with the access message "The text you
entered isn't an item on the list....." and my new item doesn't show up
on the list. However, when i go to tbl_Category it is there!!! Can
anyone help???? Is there an error with my code???

Thanks in advance

Dec 14 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.