A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

One Combo Box won't work??



 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old November 4th, 2009, 03:38 AM posted to microsoft.public.access.forms
Sklyn
external usenet poster
 
Posts: 39
Default One Combo Box won't work??

Hi, I have a form with 12 Combo Boxes and the last one won't work.
Well it works but won't 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

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:10 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 OfficeFrustration.
The comments are property of their posters.