473,397 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Syntax error

DJRhino1175
221 128KB
Expand|Select|Wrap|Line Numbers
  1. Private Sub Part_Number_NotInList(NewData As String, Response As Integer)
  2.  
  3.     On Error GoTo Part_Number_NotInList_Err
  4.  
  5.     Dim intAnswer As Integer
  6.     Dim strSQL As String
  7.  
  8.     intAnswer = MsgBox("The Part Number" & Chr(34) & NewData & _
  9.         Chr(34) & " is not currently listed." & vbCrLf & _
  10.         "Would you like to add it to the list now?" _
  11.         , vbQuestion + vbYesNo, "Part Number")
  12.  
  13.     If intAnswer = vbYes Then
  14.  
  15. 'Change area as needed
  16.  
  17.         strSQL = "INSERT INTO  tblPartNumber[CZEKCD] " & _
  18.                  "VALUES ('" & NewData & "');"
  19.         DoCmd.SetWarnings False
  20.         DoCmd.RunSQL strSQL
  21.         DoCmd.SetWarnings True
  22.         MsgBox "The new Part number has been added to the list." _
  23.             , vbInformation, "Part Number"
  24.         Response = acDataErrAdded
  25.  
  26.     Else
  27.  
  28. 'Change area of target
  29.  
  30.         MsgBox "Please choose Part Number from the list." _
  31.             , vbInformation, "Part Number"
  32.         Response = acDataErrContinue
  33.  
  34.     End If
  35.  
  36. Part_Number_NotInList_Exit:
  37.     Exit Sub
  38.  
  39. Part_Number_NotInList_Err:
  40.     MsgBox Err.Description, vbCritical, "Error"
  41.     Resume Part_Number_NotInList_Exit
  42.  
  43. End Sub
I get a "Syntax Error in INSERT INTO statement" message when running the above code.

Code compiles with no errors. I use this same code on other databases but for some reason this one is giving me fits.

This is for updating a table through a combobox that has the limit to list as yes.

I tried using a "." and "!" between "tblPartNumber[CZEKCD]" this part of the statement but it changes nothing.

Does anyone see a possible issue or reason why?

Thanks for any help provided.
Oct 9 '19 #1

✓ answered by cactusdata

I doubt you have this working anywhere. The syntax is:

Expand|Select|Wrap|Line Numbers
  1. strSQL = "INSERT INTO tblPartNumber ([CZEKCD]) " & _
  2.                  "VALUES ('" & NewData & "');"

3 788
cactusdata
214 Expert 128KB
I doubt you have this working anywhere. The syntax is:

Expand|Select|Wrap|Line Numbers
  1. strSQL = "INSERT INTO tblPartNumber ([CZEKCD]) " & _
  2.                  "VALUES ('" & NewData & "');"
Oct 10 '19 #2
DJRhino1175
221 128KB
That was it, can't believe I missed the ().

Thanks again.
Oct 10 '19 #3
NeoPa
32,556 Expert Mod 16PB
Hi DJ.

Glad that got sorted for you by CactusData but do remember how to deal with such problems in future (How to Debug SQL String).

This one was very straightforward but had it not been then your post would have been short of the required information - as explained in my linked article.

Please try to remember for future threads.

Also, I've set CactusData's post as Best Answer for you.
Oct 11 '19 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: sam | last post by:
When I run this SQL query: SELECT u.*, o.* FROM users u, orders o WHERE TO_DAYS(o.order_date) BETWEEN TO_DAYS('2003-09-20')-10 AND TO_DAYS('2003-09-20')+10
1
by: Steve | last post by:
I just spent waaaaaaaaaaaayy too much time trying to track down an error that was incorrectly reported just now, and I would like to see if someone can explain to me why it was reported that way. ...
1
by: Donald Canton | last post by:
Hi, I'm using Bjarne's book to learn C++ and am stuck on the Calc program in Section 6. Everything works fine except when I try to use istringstream to parse a token from the command line. I...
5
by: r.nikhilk | last post by:
Hi, Currently, we are porting C++ applications from 32 bit to 64 bit on AIX platform. (The current version of AIX is 5.3 and xlC verison is 8.0). We are able to compile the applications by...
2
by: david | last post by:
Anyone could give me a hand about this syntax error? Thank you. David Source Code: Dim conn As New SqlConnection(strConn) Dim daAngio As New SqlDataAdapter(strSelectStatement, conn) 'Create a...
3
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very...
4
by: nickyeng | last post by:
i calling this piece of java code in jsp : List<Customer> list = Customer.listby_page(currentRs); ... ... then it gives me the following error:
0
by: Timothy Grant | last post by:
On Thu, Aug 28, 2008 at 1:40 AM, Alexis Boutillier <alexis.boutillier@arteris.comwrote: So if you were writing C code and the file failed to compile you would still expect to have a working...
6
by: muby | last post by:
Hi everybody :) I'm modifying a C++ code in VC++ 2005 my code snippet void BandwidthAllocationScheduler::insert( Message* msg, BOOL* QueueIsFull,
14
by: calvin dong | last post by:
In my program to brute force all the factors (not including 1) of a number, there is a syntax error in my while loop. The code looks like this. number = raw_input(" Enter a number ") x = 2...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.