Results 1 to 6 of 6
  1. #1
    visidro is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Mar 2013
    Posts
    23

    Please help with syntax error

    I am having trouble seeing the error in this line ......



    CurrentDb.Execute "INSERT INTO Payments(EnrollmentDate, firstname, lastname, amount, program, classtype, pdate) SELECT inactive date, firstname, lastname, totalamount, program, classtype, Date() AS TodayDate FROM [Students Database Table] WHERE [inactive date]>#" & processingdate & "#;"


    Could some one help me see the syntax error ... it lists 'Inactive date' field as the problem
    Thank you

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Names with spaces or special characters/punctuation (underscore is exception) or are reserved words must be enclosed in [].

    This is why it is a good idea to avoid those features in naming convention.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Dont run Sql this way. Put it in a query.
    Even if you Use form params. , use queries. NOT CODE.
    or try
    docmd.runSql sSql

  4. #4
    visidro is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Mar 2013
    Posts
    23
    I know now .... it would take a big effort to change this field name now

    I tried this with same syntax error

    CurrentDb.Execute "INSERT INTO Payments(EnrollmentDate, firstname, lastname, amount, program, classtype, pdate) SELECT [inactive date], firstname, lastname, totalamount, program, classtype, Date() AS TodayDate FROM [Students Database Table] WHERE [inactive date]>#" & processingdate & "#;"

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    ranman, I like action queries in code.

    I don't see anything else wrong with syntax. What is processingdate - a variable? Are you sure it gets populated?

    Changing names would be easy with an add-in like Rick Fisher's Find and Replace - saved my sanity more than once.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    visidro is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Mar 2013
    Posts
    23
    Got it working changing the name ......

    thank you for your help
    cheers

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 11
    Last Post: 05-01-2014, 11:56 AM
  2. Replies: 3
    Last Post: 01-23-2014, 07:49 AM
  3. Replies: 3
    Last Post: 03-05-2013, 11:17 AM
  4. Replies: 6
    Last Post: 05-30-2012, 12:32 PM
  5. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums