View Single Post
  #5  
Old November 4th, 2009, 12:22 PM posted to microsoft.public.access.forms
BruceM via AccessMonster.com
external usenet poster
 
Posts: 448
Default repli

What is the exact text of the error message? Did you set the break point as
suggested? If you are unfamiliar with the process, open the VBA editor and
click the vertical gray bar to the left of the code window. This hsould
cause a dot to appear in the bar, and the line of code to be highlighted.
Now run the code by attempting to update the combo box with a value not on
the list.

Also, you could place this line of code after the strSQL line:
Debug.Print strSQL
This will cause strSQL to be written to the immediate window (press Ctrl + G
after running the code, or look for it when the code reaches the break point
you set.

Please post the INSERT for a combo box in which it works.

As mentioned, you could be having the problem is you are trying to add a
value to a Number field, in which case the quotes are incorrect.

ajay indulkar wrote:
i dont no

One Combo Box won't work??
03-Nov-09

Hi, I have a form with 12 Combo Boxes and the last one will not work.
Well it works but will not update the table/list if a new entry is added.
All the others are the same using the same code in the "On Not In List" Event.
All the rest work perfect, just the last box returns an error:

Run-time error '-2147217900 (80040e14)':
Syntax error in INSERT INTO statement.

When I click Debug it highlights "cmd.Execute" in my code.
Here is the code I am using:

Dim cmd As ADODB.Command
Dim ctrl As Control
Dim strSQL As String, strMessage As String

Set ctrl = Me.ActiveControl
strMessage = "Add " & NewData & " to list of makes?"

strSQL = "INSERT INTO t_position(Position) VALUES(""" & _
NewData & """)"

Set cmd = New ADODB.Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandType = adCmdText

If MsgBox(strMessage, vbYesNo + vbQuestion) = vbYes Then
cmd.CommandText = strSQL
cmd.Execute
Response = acDataErrAdded
Else
Response = acDataErrContinue
ctrl.Undo
End If

I have checked the properties and all appears the same as other boxes, have
also check the referring table for errors.
Any idea what would cause this so I can check that?
I see that its telling me its an issue with INSERT INTO, but I have checked
and redone that part of the code many times now.

Thanks for ur thoughts

Previous Posts In This Thread:

EggHeadCafe - Software Developer Portal of Choice
XML/XSL VB Tester
http://www.eggheadcafe.com/tutorials...vb-tester.aspx


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200911/1