Help with Not in the list (combobox)

S

SF

Hi,

I cannot have the following code to work. I received error # 3146. Can
someone help?

Private Sub Co_OrgID_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
Dim i As Integer
Dim Msg As String

If NewData = "" Then Exit Sub

Msg = "'" & NewData & "' is not currently in the list. " & vbCr & vbCr
Msg = Msg & "Do you want to add it? "

i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Organization
Category...")
If i = vbYes Then
strSQL = "INSERT INTO tblOrganization
([Org_OrganisationID],[Org_Abbreviation],[Org_ProvinceID]) " & _
"values (127,'" & NewData & "',12);"
CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If

End Sub
 
G

George

Add this line to your code, just before the CurrentDB.Execute:

Debug.Print strSQL

Open the immediate window and locate the SQL String printed out there when
the code runs. Copy the string into a new query. See what errors you get
when trying to run that query.

HTH

George
 

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