NotInList Error

G

Guest

I added the code to add data to a combo box if it does not already appear in
the list. However, I am getting the following error:

"The expression Not In List you entered as the event property setting
produced the following error: Procedure declaration does not match
description of event or procedure having the same name."

This error is also displayed whenever I click on any of the other buttons on
my form. The code for these buttons has not changed.

Can anyone please help??
 
G

Guest

Private Sub cmbBRDescr_NotInList(NewData As String, Response As Integer)

Dim strSQL As String
Dim i As Integer
Dim Msg As String

'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub

Msg = "Issue Description is not in list. Add?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "Issue Description Not Found")
If i = vbYes Then
strSQL = "Insert Into tblBRDescr (BRDescr) values (Me.BRDescr,'" &
NewData & "')"

CurrentDb.Execute strSQL, dbFailOnError

Response = acDataErrAdded
Else
Response = acDataErrContinue
End If

End Sub
 
D

Dirk Goldgar

Aria said:
Private Sub cmbBRDescr_NotInList(NewData As String, Response As
Integer)

Dim strSQL As String
Dim i As Integer
Dim Msg As String

'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub

Msg = "Issue Description is not in list. Add?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "Issue Description Not Found")
If i = vbYes Then
strSQL = "Insert Into tblBRDescr (BRDescr) values (Me.BRDescr,'" &
NewData & "')"

CurrentDb.Execute strSQL, dbFailOnError

Response = acDataErrAdded
Else
Response = acDataErrContinue
End If

End Sub

The Sub header looks okay. Check to see if you have another version of
this procedure defined in the module, with an improper header.
 
G

Guest

Thanks! I did have another procedure. It prompted me to "add" the new text,
however, when I clicked yes I got the following error:

"Run-time error: 3346. Number of query values and destination fields are not
the same"

Any ideas? The table (tblBRDescr) only has one field (BRDescr), so I am not
really sure what this error is asking of me.

Thanks again for your help!
 
S

Scott McDaniel

You're trying to insert two pieces of Data, but you've only declared one
field:

strSQL = "Insert Into tblBRDescr (BRDescr) values (Me.BRDescr,'" &
NewData & "')"

The first set of parentheses contains the ColumnNames (of which there is
one); the Second set contains the Values to be inserted (of which there are
two). I would assume you would change this as such:

strSQL = "Insert Into tblBRDescr (BRDescr) values ('" & NewData & "')"

This would insert whatever the User typed in as New data into
tblBRDescr.BRDDescr ... is this what you want to do?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top