Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Welcome to the skill header Forums. You can ask questions, get help, or help other members out. Join our Forum for free.

Waybill form not sh...
 
Notifications
Clear all

[Solved] Waybill form not showing image

3 Posts
2 Users
2 Reactions
147 Views
FStetson
Posts: 55
Topic starter
(@fstetson)
Trusted Member
Joined: 6 months ago

I ran into a problem with the code you created on my computer: with windows 11 & MS Access 365.  I added the OLE Reference you pointed out and verified code via V12 Source file.  For some reason the jpeg image would never show.  Even V12 source files failed to do any of the tasks.  After working out several issues and using error handler I rewrote the code as follows below.  I do not know if anyone else is having this issue as communications are slim.  I do hope this code will help, as on my computer (which is likely the issue) it is working 100% as desired.

Private Sub cmdInvImg_Click()
    On Error GoTo ErrorHandler

    Dim FileDialog As FileDialog
    Dim filelocation As String
    Dim getfile1 As String
    Dim getfile1Ext As String
    Dim jpNmm As String
    Dim wbmx As String
    Dim inmx As String
    
    Set FileDialog = Application.FileDialog(msoFileDialogFilePicker)
    With FileDialog
        .AllowMultiSelect = False
        .Title = "Please Select One File only..."
        
        If .Show = True Then
            getfile1 = .SelectedItems(1)
            getfile1Ext = LCase(Right(getfile1, Len(getfile1) - InStrRev(getfile1, ".")))
            
            If getfile1Ext = "jpg" Or getfile1Ext = "jpeg" Then
                ' Ensure the folder exists
                If Dir("C:\Waybill\", vbDirectory) = "" Then
                    MkDir "C:\Waybill\"
                End If
                
                wbmx = Nz(DMax("WaybillID", "tbl_Waybill"), 0)
                inmx = wbmx & TmpInv
                jpNmm = "C:\Waybill\Invoice" & inmx & ".jpg"
                
                FileCopy getfile1, jpNmm
                Me.ImgWaybill.Picture = jpNmm
                Me.txtWaybillimg = jpNmm
            Else
                MsgBox "Wrong file... only JPG image files are allowed.", vbExclamation, "|Wrong file format|"
            End If
        End If
    End With
    
    Exit Sub
    
ErrorHandler:
    MsgBox "Error: " & Err.Description, vbCritical, "Error"
End Sub
2 Replies
Posts: 8
(@quadcrazi)
Active Member
Joined: 4 months ago

I was having this error as well. I implemented your code and it now works fine!

Thank you!

Reply
FStetson
Posts: 55
Topic starter
(@fstetson)
Trusted Member
Joined: 6 months ago

Super happy, it helped you!

Reply
Share: