locked
load image to a form from all supported format ext' RRS feed

  • Question

  • i have a combolist that connected to a picture when i select a name its show the image of the student

    now i'm loading a "gif" format and i want to load "jpg" 

    i triad ".gif" & ".jpg" and more method 

     Dim a As New FileSystemObject
        Dim strStudentName As String
        Dim fl As File
        Dim IsFileExsist As Boolean
        Dim strPlace As String
         
      
        strStudentName = "D:\StudentsManager2\Pictures\" & strLastName & " " & strFirstName & ".gif" 
        
      

    the code continue with "if" 

    Monday, December 25, 2017 12:53 AM

Answers

  • for now i need it to read a "jpg" & "gif" file (when the pay me for a new db then i'll go with your idea) :)

    Hi eshay1,

    You could try someting like:

    strStudentName = "D:\StudentsManager2\Pictures\" & strLastName & " " & strFirstName & ".gif"
    IsFileExsist = a.FileExists(strStudentName)
    
    If (Not IsFileExsist) Then
        strStudentName = "D:\StudentsManager2\Pictures\" & strLastName & " " & strFirstName & ".jpg"
        IsFileExsist = a.FileExists(strStudentNam)
    End If
    
    If (Not IsFileExsist) Then
        strStudentName = "D:\StudentsManager2\Pictures\" & strLastName & " " & strFirstName & ".bmp"
        IsFileExsist = a.FileExists(strStudentNam)
    End If
    
    If (Not IsFileExsist) Then
        strStudentName = "D:\StudentsManager2\Pictures\" & strLastName & " " & strFirstName & ".png"
        IsFileExsist = a.FileExists(strStudentNam)
    End If
    
    '  all the same including the City
    
    
    
    If (IsFileExsist) Then
        StudentPicture.Picture = strStudentName
        StudentPicture.Visible = True
    End If
    

    Imb.

    • Marked as answer by eshay1 Monday, December 25, 2017 10:55 PM
    Monday, December 25, 2017 10:22 PM

All replies

  • Hello,

    Do you use image control? Please use Image.Picture Property (Access) to specify a bitmap or other type of graphic to be displayed on the specified control. Make sure strStudentName is the correct full path of the image, then you could use

    Dim ctlImage As Control
    Set ctlImage = Me.ImageControlName
    ctlImage.Picture = strStudentName 

    You could also have a field to store the image path and then set the control source into that field, then Access would load the images for each record.

    Please visit

    https://stackoverflow.com/questions/25856575/adding-images-into-forms-from-external-sources-using-paths

    In addition, is there any issue with thread below, if not, I would suggest you mark the helpful reply as answer to close previous thread.

    #capture image from a webcam into a for and

    https://social.msdn.microsoft.com/Forums/office/en-US/9cfe0270-917e-42a0-9e14-823e5e5fe763/capture-image-from-a-webcam-into-a-for-and?forum=accessdev

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Monday, December 25, 2017 6:01 AM
  • ok i well explain again with the all code 

    this code open an image from a folder by a combobox now its opening only gif files. 

    i want to add more ext' (jpg,bmp) 

    Private Sub cmb95_Change()
    On Error GoTo ErrorHandler
        
        Dim str
        Dim strLastName As String
        Dim strFirstName As String
        
        str = Split(Me![cmb95])
        Me.RecordsetClone.FindFirst "[stusentid]='" & str(0) & "'"
        Me.Bookmark = Me.RecordsetClone.Bookmark
        
        strLastName = Me![lastname]
        strFirstName = Me![firstname]
        
        ' init image
       
     
        StudentPicture.Visible = False
        On Error GoTo PictureHandler
            
        Dim a As New FileSystemObject
        Dim strStudentName As String
        Dim fl As file
        Dim IsFileExsist As Boolean
        Dim strPlace As String
    
       
        strStudentName = "D:\StudentsManager2\Pictures\" & strLastName & " " & strFirstName & ".gif"
        'Set fl = a.GetFile(strStudentName)
        
        IsFileExsist = a.FileExists(strStudentName)
        If IsFileExsist Then
            StudentPicture.Picture = strStudentName
            StudentPicture.Visible = True
           
            
        Else
       
            strPlace = [city].OldValue
            strStudentName = "D:\StudentsManager2\Pictures\" & strLastName & " " & strFirstName & " " & strPlace & ".gif"
            IsFileExsist = a.FileExists(strStudentName)
            If (IsFileExsist) Then
                StudentPicture.Picture = strStudentName
                StudentPicture.Visible = True
            End If
        End If
        
        Exit Sub
    PictureHandler:
        Exit Sub
    ErrorHandler:
        MsgBox Err.Description & " " & Err.Number
        Resume Next
    
    End Sub


    Monday, December 25, 2017 7:10 PM
  • i want to add more ext' (jpg,bmp)

    Hi eshay1,

    Instead of constructing the filenaam from LastName and FirstName, and occasionaly Place, with different file-extensions, you could also store the whole filename including the extension. This will always work.

    Imb.

    Monday, December 25, 2017 7:26 PM
  • i want to add more ext' (jpg,bmp)

    Hi eshay1,

    Instead of constructing the filenaam from LastName and FirstName, and occasionaly Place, with different file-extensions, you could also store the whole filename including the extension. This will always work.

    Imb.

    sorry for my comment but this forum have to put 2 tags 1.answer 2.Suggestions

    if you have an answer put it don't have put your Suggestions and if the method is wrong Write it 

    I apologize if I hurt anyone

    this is a working code on a 7 office pc's for a long time 

    Monday, December 25, 2017 8:11 PM
  • sorry for my comment but this forum have to put 2 tags 1.answer 2.Suggestions

    if you have an answer put it don't have put your Suggestions and if the method is wrong Write it 

    I apologize if I hurt anyone

    this is a working code on a 7 office pc's for a long time 

    Hi eshay1,

    I do not understand your reaction in full extent.

    Your code is working for a long time, but apparently it is not working satisfactory, else you wouldn't want it to extend.

    You can add code for tif files, you can add code for jpg files, you can add code for png files, and how many more to come.

    One day it is better to go to an other way of working. Therefore you have these DISCUSSION forums.

    Imb.

    Monday, December 25, 2017 8:32 PM

  • You can add code for tif files, you can add code for jpg files, you can add code for png files, and how many more to come.

    One day it is better to go to an other way of working. Therefore you have these DISCUSSION forums.

    Imb.

    hi lmb

    i got this db to fix it i rebuild it and made Dozens of additions but there some codes i didn't touched 

    because as you know getting samone alse db and start fixing it can be A bottomless pit 

    for now i need it to read a "jpg" & "gif" file (when the pay me for a new db then i'll go with your idea) :)

    in regards eshai

    Monday, December 25, 2017 8:59 PM
  • for now i need it to read a "jpg" & "gif" file (when the pay me for a new db then i'll go with your idea) :)

    Hi eshay1,

    You could try someting like:

    strStudentName = "D:\StudentsManager2\Pictures\" & strLastName & " " & strFirstName & ".gif"
    IsFileExsist = a.FileExists(strStudentName)
    
    If (Not IsFileExsist) Then
        strStudentName = "D:\StudentsManager2\Pictures\" & strLastName & " " & strFirstName & ".jpg"
        IsFileExsist = a.FileExists(strStudentNam)
    End If
    
    If (Not IsFileExsist) Then
        strStudentName = "D:\StudentsManager2\Pictures\" & strLastName & " " & strFirstName & ".bmp"
        IsFileExsist = a.FileExists(strStudentNam)
    End If
    
    If (Not IsFileExsist) Then
        strStudentName = "D:\StudentsManager2\Pictures\" & strLastName & " " & strFirstName & ".png"
        IsFileExsist = a.FileExists(strStudentNam)
    End If
    
    '  all the same including the City
    
    
    
    If (IsFileExsist) Then
        StudentPicture.Picture = strStudentName
        StudentPicture.Visible = True
    End If
    

    Imb.

    • Marked as answer by eshay1 Monday, December 25, 2017 10:55 PM
    Monday, December 25, 2017 10:22 PM
  • thank you very much lmb.

    you are the man. Appreciate your patience and help

    in regards eshai

     
    Monday, December 25, 2017 10:59 PM