Results 1 to 15 of 15
  1. #1
    mannyy12 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2020
    Posts
    23

    Post attachments


    Hey
    1. I would like to insert pictures in attachments with hotkey. Is it possible?
    2. How many photos can I add to attachments?
    3. Is it possible to display the pictures after moving the mouse over the attachment? (under the cursor)

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    1. It is possible but complicated. https://sourcedaddy.com/ms-access/wo...nt-fields.html
    Embedding files in table uses up Access 2GB size limit. Usually better to leave files external and save path to file into a text field.
    2. As many as Access file size limit will allow.
    3. Perhaps with event code in a form.
    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
    mannyy12 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2020
    Posts
    23
    I am beginner in acces.
    I want to upload photos to the database, I have a lot of them (10k +) in the files on the disk or in the excel file thrown there for comments as a background.
    How to take a database of such pictures as soon as possible, and how could you tell me what form you could do?




    `` 1 Usually better to leave files external and save path to file into a text field. ''
    Could you tell me how to do this as soon as possible to upload thousands of photos?




    `` 3. Perhaps with event code in a form. ''
    Do you have the code?

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    `` 1 Usually better to leave files external and save path to file into a text field. ''
    Could you tell me how to do this as soon as possible to upload thousands of photos?
    there are so many ways this might be organised but assuming

    a) all your pictures are in one folder
    b) you have a single table

    the code is very simple

    a) I'll call the table tblPhotos and it has a single text field called photoPath

    b) in a new module have the following code

    Code:
    Option Compare Database
    Option Explicit
    
    Function getPhotos()
    dim s as string
    dim path as string
    dim sql as string
    
        path="C:\myPhotos\" 'change name to the path where you store the photos, don't forget the last backslash
    
        s=dir(path)
        while s<>""
             if len(path & s)>254 then 
                 msgbox s & " - this file name is too long and won't be imported
             else
                 sql="INSERT INTO tblPhotos (photoPath) Values('" & path & s & "')"
                debug.print sql
                currentdb.execute sql
            end if
            s=dir
        wend
    
    end Function
    c) in the immediate window type ?getPhotos

    your table will be populated with all the file names, regardless of type (so will include word/excel files etc if they are in the same folder). May take some time depending on how many photos

    d) now create a multiple items form (on the ribbon Create>more forms) based on the table

    e)
    in design view add an image control and set its controlsource to photoPath

    f) run the form and you should see all the images in a list

    note the text field (photoPath) has a maximum of 255 characters so make sure the length of your folder+file name is less than this amount otherwise it won't be imported

  5. #5
    mannyy12 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2020
    Posts
    23
    ``e) in design view add an image control and set its controlsource to photoPath

    f) run the form and you should see all the images in a list``

    how to do it exactly?

  6. #6
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    you need to learn some basics

    open the form in design view - see the image control on the ribbon - drag it onto the form in the detail section

    to run it switch to form view
    Click image for larger version. 

Name:	Capture.PNG 
Views:	19 
Size:	65.8 KB 
ID:	41392

  7. #7
    mannyy12 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2020
    Posts
    23
    how to set its control source to PhotoPath??

  8. #8
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    if you can't see the property sheet, open it by clicking the property sheet button on the ribbon. Controlsource is the top property under the data tab

  9. #9
    mannyy12 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2020
    Posts
    23
    I did everything but it doesn't work

    c) in the immediate window type ?getPhotos
    i dont understand this point

  10. #10
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    what does 'doesn't work' mean? you get an error? no errors but files not loaded? but something else

    c) in the immediate window type ?getPhotos
    i dont understand this point
    if you don't know what this means, then the code will not have run

    If the immediate window is not open then in the vba window, click on View>immediate window

  11. #11
    mannyy12 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2020
    Posts
    23
    Quote Originally Posted by Ajax View Post
    what does 'doesn't work' mean? you get an error? no errors but files not loaded? but something else

    if you don't know what this means, then the code will not have run


    I have no error, but only one file that I chose from the disk loaded, the rest of the files did not

  12. #12
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    you are not choosing a file, you are choosing a folder

    suggest copy and paste the code you are actually using

  13. #13
    mannyy12 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2020
    Posts
    23
    Quote Originally Posted by Ajax View Post
    you are not choosing a file, you are choosing a folder

    suggest copy and paste the code you are actually using
    Option Compare Database
    Option Compare Database
    Option Explicit


    Function getPhotos()
    Dim s As String
    Dim path As String
    Dim sql As String


    path = "C:\Users\kqali\Desktop\Nowy folder\media"


    s = Dir(path)
    While s <> ""
    If Len(path & s) > 254 Then
    MsgBox s & " - this file name is too long and won't be imported"
    Else
    sql = "INSERT INTO tblPhotos (photoPath) Values('" & path & s & "')"
    Debug.Print sql
    CurrentDb.Execute sql
    End If
    s = Dir
    Wend


    End Function


    and in immediate :

    ?getPhotos


    when i do this ``open the form in design view - see the image control on the ribbon - drag it onto the form in the detail section`` i must choose file in my disc

  14. #14
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    you have option compare database twice - remove one of them

    I provided



    [CODE]path="C:\myPhotos\" 'change name to the path where you store the photos, don't forget the last backslash[/CODE]



    you have put

    path = "C:\Users\kqali\Desktop\Nowy folder\media"


    you have not followed my instructions - now highlighted in red.

    You may have done, but it has been lost because you have not used the code tags. Please get in the habit of using them (very easy once you have pasted your code, highlight it and click the # button)

    The code I provided works based on the very limited information provided - so the implication is your folder only contains one file (sub folders are ignored)

  15. #15
    mannyy12 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2020
    Posts
    23
    now look like thisL:

    Option Compare Database
    Option Compare Database
    Option Explicit


    Function getPhotos()
    Dim s As String
    Dim path As String
    Dim sql As String


    path = "C:\Users\kqali\Desktop\media" / code


    s = Dir(path)
    While s <> ""
    If Len(path & s) > 254 Then
    MsgBox s & " - this file name is too long and won't be imported"
    Else
    sql = "INSERT INTO tblPhotos (photoPath) Values('" & path & s & "')"
    Debug.Print sql
    CurrentDb.Execute sql
    End If
    s = Dir
    Wend


    End Function




    but I still insert only one photo, there are several photos in the folder


    Maybe i will give you team viewer and share , and will you help me?

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

Similar Threads

  1. Attachments
    By DevState in forum Access
    Replies: 17
    Last Post: 03-01-2019, 01:24 PM
  2. Attachments
    By DevState in forum Forms
    Replies: 2
    Last Post: 01-14-2019, 08:06 AM
  3. Replies: 2
    Last Post: 01-29-2014, 03:19 PM
  4. Attachments
    By JayX in forum Access
    Replies: 5
    Last Post: 12-27-2011, 03:08 PM
  5. attachments
    By chiefmsb in forum Access
    Replies: 1
    Last Post: 06-28-2011, 04:20 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