Problem with "Not In List" event

G

Guest

The table source for the combo box doesn't have anything in it and I have
code in the "not in list" event to add to the list. When I try to add
something to the list I get the following error:

A problem occurred while Microsoft Access was communication with the OLE
server or ActiveX Control.

I have another subform with a variation of the code and it works fine.

Cheers
 
G

Guest

Sounds weird.

1- have you compiled your code recently? you should.
2- have you compacted the db recently? you should.
3- Post your code so we can take a look at it in detail.
 
G

Guest

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 = "'" & NewData & "' is not currently in the product list." & vbCr &
vbCr
Msg = Msg & "Do you want to add it?"

I = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Product type...")
If I = vbYes Then
strSql = "Insert Into lkup_JS ([JSat]) " & _
"values ('" & NewData & "');"
CurrentDb.Execute strSql, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
 

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

Top