Results 1 to 5 of 5
  1. #1
    ludovic_44 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2014
    Location
    mauritius
    Posts
    15

    Send data to a table from a form by a submit button

    Hi All



    I have an issue with my form where i have a submit button
    My table name is tblReverse
    field are as per attached

    When i click on the submit button to send the data to a table, it gives me an error as per attached

    Is there a problem with my code:
    CurrentDb.Execute "insert into tblreverse(txtRequestedBy,dtRequestedDate,txtPrevB illTo,txtOrderNo,txtInvoiceNo,txtLicenceNo,txtInst ruction,attAttachment,mmRemarks)" & _
    "values(""," & Me.ccReq & ",'" & Me.ccDate & "','" & _
    Me.ccPrev & ",'" & Me.ccOrder & ",'" & Me.ccInvoice & ",'" & Me.ccLic & ",'" & Me.ccInst & ",'" & Me.ccAtt & ",'" & Me.ccRem & "')"

    Im new in VBA and i cant understand these code which i get from google

    Can you please help me ,

    Thanking you


    Attachment 18044Attachment 18045Attachment 18045& ",'" & Me.ccRem & "')"

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Use a variable for the SQL and this method to see how it's coming out.

    http://www.baldyweb.com/ImmediateWindow.htm

    offhand, your use of delimiters is inconsistent and may not be correct for each data type. Basically date values use #, text values ' and numeric values no delimiter.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ludovic_44 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2014
    Location
    mauritius
    Posts
    15
    HI
    I did what you told me, i google, but still i have another error now:

    Run-time error '3134':
    Syntax error in INSERT INTO statement


    I changed my code to :
    CurrentDb.Execute "insert into tblreverse(txtRequestedBy,dtRequestedDate,txtPrevB illTo,txtOrderNo,txtInvoiceNo,txtLicenceNo,txtInst ruction,attAttachment,mmRemarks)" & _
    "values(" & Me.ccReq & ", # & Me.ccDate & #, " & _
    Me.ccPrev & ", " & Me.ccOrder & ", " & Me.ccInvoice & ", " & Me.ccLic & ", " & Me.ccInst & ", " & Me.ccAtt & ", " & Me.ccRem & ")"

    I really cant figure it out where lies the issue
    Can you please have a look

    Thanking you

  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,901
    Missing quote marks. The delimiters are literal text and need to be within the quote marks, along with the comma.

    "values(" & Me.ccReq & ", #" & Me.ccDate & "#, " & _

    If any of those fields are text type, the value parameters need apostrophe delimiters.

    Why are you using Execute to create record in table? Why not a bound form for data entry?
    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
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'll step out of the way.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 3
    Last Post: 05-30-2014, 11:18 AM
  2. Submit and retrieve data in a form
    By Bertrand82 in forum Import/Export Data
    Replies: 1
    Last Post: 10-05-2012, 11:44 AM
  3. Submit Button In Form
    By smarty84handsome in forum Forms
    Replies: 3
    Last Post: 01-12-2012, 11:17 PM
  4. Submit button in access form
    By Melo in forum Forms
    Replies: 2
    Last Post: 09-25-2010, 08:37 AM
  5. Replies: 6
    Last Post: 02-09-2010, 07:53 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