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

    Vba code to transfer attachment to a table

    HI All,



    I have a form with 8 textboxes which users input and transfer all these data to a table when pressed on a button(VBA Code)

    Below is the vba code i used, which works perfectly

    CurrentDb.Execute "INSERT INTO tblreverse(txtRequestedBy,dtRequestedDate,txtPrevB illTo,txtOrderNo,txtInvoiceNo,txtLicenceNo,txtInst ruction,mmremarks) " & _
    "values('" & Me.ccReq & "', #" & Format(Me.ccDate, "yyyy/mm/dd") & "#, '" & _
    Me.ccPrev & "', '" & Me.ccOrder & "', '" & Me.ccInvoice & "', '" & Me.ccLic & "', '" & Me.ccInst & "','" & Me.ccRem & "')"

    In the table tblreverse, i have also a field name which is "attAttachment".
    What i'm trying is to insert a textbox in my form names ccAtt and when click on the button, the attachment goes to the table.

    Here;s how i put the code

    CurrentDb.Execute "INSERT INTO tblreverse(txtRequestedBy,dtRequestedDate,txtPrevB illTo,txtOrderNo,txtInvoiceNo,txtLicenceNo,txtInst ruction,mmremarks,attAttachment) " & _
    "values('" & Me.ccReq & "', #" & Format(Me.ccDate, "yyyy/mm/dd") & "#, '" & _
    Me.ccPrev & "', '" & Me.ccOrder & "', '" & Me.ccInvoice & "', '" & Me.ccLic & "', '" & Me.ccInst & "','" & Me.ccRem & "','" & Me.ccAtt & "')"

    But it does not function

    Can you please show me how to figure this out

    Thanking you

    Ludovic

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602
    This is UNBOUND form?

    Attachment field is a type of multi-value field. Requires special handling. Review:

    https://www.accessforums.net/program...vba-21259.html

    https://social.msdn.microsoft.com/Fo...orum=accessdev
    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.

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

Similar Threads

  1. Replies: 1
    Last Post: 09-04-2014, 11:10 AM
  2. Replies: 2
    Last Post: 08-11-2014, 12:57 PM
  3. Send Email with Attachment VBA Code
    By kevins in forum Programming
    Replies: 2
    Last Post: 10-03-2012, 01:21 PM
  4. Replies: 2
    Last Post: 06-15-2012, 07:41 PM
  5. How do you file save an 'Attachment' content through code?
    By morespamforya in forum Programming
    Replies: 3
    Last Post: 08-06-2010, 08:58 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