469,602 Members | 1,984 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

Combobox Not In List Event

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
Integer)

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.AddNew
rstCat!Category = NewData
rstCat.Update
MsgBox "'" & NewData & "' added to list of Categories",
vbOKOnly + vbInformation, "Category Added!"
Else
MsgBox "'" & NewData & "' has not been added to list of
Categories!", vbInformation + vbOKOnly, "Process Cancelled!"
IsNull (Me.R_Category)
End If

rstCat.Close
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
Bec

Dec 14 '05 #1
0 1081

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by NCrum | last post: by
5 posts views Thread by ross kerr | last post: by
reply views Thread by | last post: by
6 posts views Thread by tbrown | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.