Not In List event - new value added but access 2002 says no

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I must be missing something here. When complete I will have a form with many
combo boxes where values can be entered into the control. I have built a
function that I will call from the not in list event to add the value to the
database. This might be the problem, I have written a query and saved it in
the database. The combo box row souce is set to the name of this query.

I have verified the query works, the function works as envisioned, I set the
response to acDataErrAdded so access can requery the combo box for me. Yet
after setting the response value when the code completes executing the event
I get the standard access error message. I am at a loss as to why the new
value is added to the table and when the combo box is requeried access does
not find the new value to compare against.

I have included the code too.

Event Procedure
blnDataInserted = basGlobals.AddListItem(ctl:=Me.cboArea,
NewValue:=NewData)
If blnDataInserted Then
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If

Function
Public Function AddListItem(ctl As ComboBox, NewValue As String) As Boolean

Dim strErrorProcedure As String
Dim blnFuncResult As Boolean

strErrorProcedure = "CMPSupport.basGlobals.AddListItem"

Select Case ctl.Name
Case Is = "cboArea"
With moCmd 'module level command object
.CommandType = adCmdStoredProc
.CommandText = "spInsertArea"
.Parameters.Append .CreateParameter(Name:="NewArea",
Type:=adVarChar, Direction:=adParamInput, Size:=50, Value:=NewValue)
.Execute Options:=adExecuteNoRecords
'clear the parameters collections for use next time
.Parameters.Refresh
End With
End Select
blnFuncResult = True
AddListItem = blnFuncResult
End Function
 
I found a problem as same as yours in the past.it might be a bug.it happens
in some circs,so you can try add "distinct" in you combo rowsource.That will
be helpfull.
 
Back
Top