Results 1 to 5 of 5
  1. #1
    DerekAwesome is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    15

    Why am I getting this Missing Operator in my insert into statement?

    So the system I'm coding right now is for account creation. The code I'm using to append the new account information is as follows:


    Code:
    CurrentDb.Execute "INSERT INTO AcctInfo (Username, Password, AcctOwner, Email, CreationDate) VALUES (" & TextUsername.Value & "," & TextPassword.Value & "," & TextName.Value & "," & TextEmail.Value & "," & Date & ")"
    I'm getting an error when it gets to the email field. If I have an @ in the text box (which I have to to enter the email), I get a Missing operator, and the error message displays the text in the email text box. If it doesn't have an @, I get a too few parameters (and either an expecting 3 or expecting 2)

    Are there syntax errors in this statement? Is there something wrong with using an @ symbol in the text field?

    Any help would be greatly appreciated.

    Edit: FIXED Missing Operator with Chr(39) delimiters around TextEmail.Value. New Code:
    Code:
    CurrentDb.Execute "INSERT INTO AcctInfo (Username, Password, AcctOwner, Email, CreationDate) VALUES (" & TextUsername.Value & "," & TextPassword.Value & "," & TextName.Value & "," & Chr$(39) & TextEmail.Value & Chr$(39) & "," & Date & ")"



    I'm still getting a too few parameters error (expecting 2). Why is this?
    It's also important to note I had previously opened the database as a DAO.Recordset earlier, but I still closed it before running this line. Could this be the issue?

  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
    52,929
    Values for text fields require apostrophe delimiters. Date fields require # delimiters. Value is default property and do not have to type it. Good idea to qualify reference to controls with form name. Can use the Me alias.

    CurrentDb.Execute "INSERT INTO AcctInfo (Username, Password, AcctOwner, Email, CreationDate) VALUES ('" & Me.TextUsername & "', '" & Me.TextPassword & "', '" & Me.TextName & "', '" & Me.TextEmail & "', #" & Date() & "#)"
    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
    DerekAwesome is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    15
    Thanks for the info, I made an update to the original post after figuring that out (I had yet to see your reply). Guess I should have read some other posts before throwing one up.

    Anyway, the issue now remains that I have a too few parameters (expecting 2) errors. What could this be caused by? If you need to see more of my code, let me know.

    EDIT: I threw in the commas and hashtags and it works PERFECTLY! thanks June7!

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You haven't use delimiters on all the fields as shown in my suggestion. I assume the fields are all text except for CreationDate.
    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.

  5. #5
    DerekAwesome is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    15
    Yeah, I re-did it the way you suggested and it worked perfectly

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. Unable to fix a missing operator error
    By dhaneshjs in forum Access
    Replies: 6
    Last Post: 05-25-2011, 10:14 AM
  3. Syntax Error...missing operator
    By jgelpi16 in forum Programming
    Replies: 14
    Last Post: 09-09-2010, 11:35 AM
  4. Error 3075 Missing Operator
    By KLynch0803 in forum Queries
    Replies: 5
    Last Post: 02-11-2010, 01:13 PM
  5. Missing Operator error
    By data123 in forum Forms
    Replies: 1
    Last Post: 03-15-2009, 04:34 PM

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