Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    graccess is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    78

    Question error 3075...making me nuts

    First time posting here and a newbie at Access so please forgive me if I miss a pertinent piece of info, will be more than happy to revise and thanks in advance for helping. Building a form that will allow me to add several fields of user input simultaneously from a combo box, text, check box, and a date into my subform.

    Upon clicking the button I receive the following error: Run-time error '3075' Syntax error (missing operator) in query expression 'test','test corp','test sector','test subsector','#2014-01-11#','-1')'.

    Private Sub cmdAdd_Click()


    'add data to table
    CurrentDb.Execute "INSERT INTO [company table] ([ticker], [company], [sector], [subindustry], [lastupdate], [flag]) " & _
    " VALUES(" & Me.cboTicker & "','" & Me.txtCompany & "','" & Me.txtSector & "','" & Me.txtSubIndustry & "','" & _
    Format(dtLastupdate, "\#yyyy-mm-dd\#") & "','" & Me.cbxFlag & "')"

    Not sure what VBA is finding invalid....

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,529
    You don't want the apostrophes around the date value, just the #. It also appears you have an apostrophe after the first value but not before. They need to match up. Numeric data types wouldn't have any delimiter. This may help:

    BaldyWeb-Immediate window
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Note only text fields should be enclosed in quotes. It looks like your date has both quotes and pound signs. I don't think that is correct.
    Also, if your cbxFlag field is a numeric field and not text, it should not have quotes around it either.

    A little trick that I often do when trying to build and debug SQL code is to write it out to Message Box so I can visually look at what is being built first before executing it to make sure it looks correct. Once you have it working, you can get rid of the Message Box in your code.

  4. #4
    graccess is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    78
    Thanks Paul and Joe. When I remove the quotes around the date field I receive a compile error: expected: expression.

    this is how i rewrote the datefield expression after removing the quotes:
    \#yyyy-mm-dd\#

    Paul, you noted I have an apostrophe after the first value and not before, can you be more specific, I don't see that although my eyes are getting a bit blurry.

    thx

  5. #5
    graccess is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    78
    Disregard, found it and I believe its fixed now but of course a new error was generated, 3134 INSERT INTO error, which I know probably warrants a separate thread but if you happen to see that error in that syntax written earlier, please let me know.
    thx again. both your replies resolved the 3075 error.

  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,529
    Have you tried the technique in post 2 to see the finished SQL? What's the text of the error message?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    Is dtLastupdate a date or text type field?
    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.

  8. #8
    graccess is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    78
    Run-time error '3134:

    Syntax error in INSERT INTO statement

  9. #9
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,529
    And what is the SQL?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    graccess is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    78
    dtLastupdate is a date field



  11. #11
    graccess is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    78
    SELECT [Companytable].[Company ID], [Companytable].Ticker FROM Companytable ORDER BY [Ticker];

  12. #12
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,529
    That's a simple SELECT query, not an append query.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #13
    graccess is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    78
    didn't get that far yet. this is the only code I have to add my input fields into the subform.

    CurrentDb.Execute "INSERT INTO companytable (ticker, company, sector, subindustry, lastupdate, flag) " & _
    " VALUES(" & Me.cboTicker & " ','" & Me.txtCompany & "','" & Me.txtSector & "','" & Me.txtSubIndustry & "','" & _
    format (me.dtLastupdate, \#yyyy-mm-dd#\) & me.cbxFlag & ")"

    now just getting a compile error.

  14. #14
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,529
    If you use the technique I mentioned you should see the problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  15. #15
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,529
    Oh, and the Format() function still needs the double quotes.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 03-05-2013, 11:17 AM
  2. RunTime error 3075
    By Compufreak in forum Access
    Replies: 3
    Last Post: 07-25-2012, 02:18 AM
  3. Replies: 6
    Last Post: 05-30-2012, 12:32 PM
  4. Replies: 5
    Last Post: 03-27-2012, 01:40 PM
  5. Getting Error 3075
    By boywonder in forum Programming
    Replies: 4
    Last Post: 05-23-2011, 05:06 PM

Tags for this Thread

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