Results 1 to 5 of 5
  1. #1
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150

    Attaching An Attachment

    Hi Guys

    Code:
    Private Sub Command6_Click()Dim StrSQL As String
    Dim rec As String
    Dim but As String
    
    
    
    
    If IsNull(Me.Text0) Then
     MsgBox "Please Enter Workstation ID", vbInformation, "Workstation ID Required"
     Me.Text0.SetFocus
    ElseIf IsNull(Me.Text3) Then
     MsgBox "Please Enter Workstation Description", vbInformation, "Workstation Description Required"
     Me.Text3.SetFocus
    Else
     CurrentDb.Execute "INSERT INTO Workstation_tbl (Workstation_ID,Workstation_Desciption) " & "VALUES ('" & Me.Text0 & "','" & Me.Text3 & "')"
     MsgBox " Workstation Details Saved Successfully !!!"
     Me.Text0.Value = Null
     Me.Text3.Value = Null
     Me.Text0.SetFocus
    End If
    End Sub



    Above is the code i have written to insert data. Now i want to save an attachment along with the values from text0 and text3. How do this part?

    Appreciate your help.


    Thanks in advance

  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
    I personally don't use the attachment data type (I don't think many established developers do), I save the path to the file . To do that, you'd simply put that path into another textbox and add it to your SQL.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150
    Hi

    instead of using a path, is there is a way to insert the image into the table via above button click code?

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    sure there is. research ms access vba update attachment field and you will find it's done via DAO.
    You will need to concern yourself not only with adding the attachment, but sooner or later, updating and/or deleting it as well. Then there is the aspect of ensuring the field you will attempt these actions on is of the attachment type. Maybe you can see now that there's more to it than simply updating a field with an attachment, thus is really a bit much to deal with here and do it well.

    Then there is the 'fact' that was already mentioned, and I count myself as one who would not do this unless there was a case where it was the best solution and I can't think of what that might be. You could find yourself quickly reaching the table size limit, to say nothing of the db size limit as a whole.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    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. Storing and Attaching pdf Files
    By EddieN1 in forum Database Design
    Replies: 4
    Last Post: 02-19-2015, 07:09 AM
  2. Replies: 3
    Last Post: 10-13-2014, 05:48 PM
  3. Replies: 1
    Last Post: 09-04-2014, 11:10 AM
  4. Attaching Files
    By jlclark4 in forum Forms
    Replies: 7
    Last Post: 01-20-2011, 03:01 PM
  5. Attaching a file to a record
    By ildanach in forum Forms
    Replies: 0
    Last Post: 08-16-2008, 07:57 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