Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combolist create new record problem via notInlist

Status
Not open for further replies.

azzi2000

MIS
Jan 28, 2004
145
0
0
US
I am using a basic form.
I have an unbound combo list to pull listing of items. (The item is not the primary key but however it is indexed).
What I am trying to accomplish is this:
When the user enter a non existing item, I prompt the user if they want to create the item. (the code is in On not in list:
The property for the Cmbitem are as follows:
CmboItem:
unbound
Limit to list=Yes
Events=
---- After Update: (default by access)
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Item] = '" & Me![CmbItem] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End sub

Events=
---- On Not in List:
Private Sub CmbItem_NotInList(NewData As String, Response As Integer)
Dim sAns As String
sAns = MsgBox("Create item " & NewData, vbQuestion + vbYesNo, "New")
If sAns = vbYes Then
'????????????????????????????????????????????????
'*** This is where I am having the problem,
' It will not execute the addition of new record
'it gets stuch in a loop when sAns = vbYes
' ???????????????????????????????????????????????
DoCmd.GoToRecord , , acNewRec
Item = NewData
CmbItem = Item
End If
End Sub

Please advice,
Thank you
Dré
 
I'm wondering if it could have something to do with your combobox not being bound? If so, you may want to consider using a bound combobox.

If your interested, I have code to enter a new record via a bound combobox when the notinlist event is triggered.
 
03SCBeast:
I tried to bound it but I am getting same result.
Yes I would appreciate code as well.
Thank you.
Dré
 
03SCBeast:
Do you have the code please.
Thank you.
Dré
 
I was able to fix it,
I forget the allowaddition=Yes
Thank you.
dre
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top