Results 1 to 19 of 19

Thread: Runtime error 76 "path not found"

  1. #1
    Junior Member MernaSly07's Avatar
    Join Date
    Oct 12
    Location
    indonesia
    Posts
    27

    Unhappy Runtime error 76 "path not found"

    Private Sub Cmd_CARI_Click()
    Dim path As String
    MsgBox path
    With CommonDialog1
    .DefaultExt = ".jpg .png"
    .InitDir = GBLpathFile
    .DialogTitle = " Buka gambar Karyawan"
    .Flags = cdlOFNHideReadOnly
    .Filter = "Gambar Files 1 (*.jpg)|*.jpg|Gambar Files 2 (*.png)|*.png|Gambar Files 3 (*.gif|*.gif"
    .FilterIndex = 1
    .ShowOpen
    If Trim(.FileName) <> "" Then
    Text1.Text = .FileName
    strPATHGAMBAR = .FileName
    Image1.Picture = LoadPicture(Text1.Text)
    If Right(GBLpathFile, 1) = "\" Then
    path = path & "\" & "Daftar Karyawan" & "\" & Year(Date) & "\" & UCase(Format(Date, "MMMM")) & "\" & .FileTitle
    Else
    path = path & "\" & "Daftar Karyawan" & "\" & Year(Date) & "\" & UCase(Format(Date, "MMMM")) & "\" & .FileTitle
    End If

    FileCopy strPATHGAMBAR, path

    End If
    End With
    End Sub

    picture not found ..
    what's wrong?
    please help me
    the underline sentence is wrong..

  2. #2
    Junior Member MernaSly07's Avatar
    Join Date
    Oct 12
    Location
    indonesia
    Posts
    27

    Re: Runtime error 76 "path not found"

    FileCopy strPATHGAMBAR, path this is error
    please help me

  3. #3
    Frenzied Member
    Join Date
    May 06
    Location
    some place in the cloud
    Posts
    1,631

    Re: Runtime error 76 "path not found"

    Code:
    Private Sub Cmd_CARI_Click()
    
    Dim path As String
    
    MsgBox path
    
    With CommonDialog1
        .DefaultExt = ".jpg .png"
        .InitDir = GBLpathFile
        .DialogTitle = " Buka gambar Karyawan"
        .Flags = cdlOFNHideReadOnly
        .Filter = "Gambar Files 1 (*.jpg)|*.jpg|Gambar Files 2 (*.png)|*.png|Gambar Files 3 (*.gif|*.gif"
        .FilterIndex = 1
        .ShowOpen
        If Trim(.FileName) <> "" Then
            Text1.Text = .FileName
            strPATHGAMBAR = .FileName
            Image1.Picture = LoadPicture(Text1.Text)
            If Right(GBLpathFile, 1) = "\" Then
                path = path & "\" & "Daftar Karyawan" & "\" & Year(Date) & "\" & UCase(Format(Date, "MMMM")) & "\" & .FileTitle
            Else
                path = path & "\" & "Daftar Karyawan" & "\" & Year(Date) & "\" & UCase(Format(Date, "MMMM")) & "\" & .FileTitle
            End If
    
            FileCopy strPATHGAMBAR, path
    
        End If
    End With
    
    End Sub
    I don't know if this is the solution, but:
    Inside the:
    Code:
            If Right(GBLpathFile, 1) = "\" Then
                path = path & "\" & "Daftar Karyawan" & "\" & Year(Date) & "\" & UCase(Format(Date, "MMMM")) & "\" & .FileTitle
            Else
                path = path & "\" & "Daftar Karyawan" & "\" & Year(Date) & "\" & UCase(Format(Date, "MMMM")) & "\" & .FileTitle
            End If
    both results (Then & Else) are equal

    also, it would be better if you format the month to "mmmm" instead of "MMMM"
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

  4. #4
    PowerPoster
    Join Date
    Jul 06
    Location
    Maldon, Essex. UK
    Posts
    5,144

    Re: Runtime error 76 "path not found"

    The implication of the error is that the path: 'C:\Daftar Karyawan\2012\OCTOBER\' doesn't exist

  5. #5
    PowerPoster
    Join Date
    Feb 12
    Location
    West Virginia
    Posts
    4,957

    Re: Runtime error 76 "path not found"

    I am surprised no one pointed this out
    Code:
    If Right(GBLpathFile, 1) = "\" Then
                path = path & "\" & "Daftar Karyawan" & "\" & Year(Date) & "\" & UCase(Format(Date, "MMMM")) & "\" & .FileTitle
    Here if your path ends in "\" your are adding another "\" to it which would make it invalid

    Of course I do not know what is in your path variaible so that may or may not be the problem but is surely incorrect. You need to remove the part in red.

    You should also check to see what the path holds after it is built and then see if that path actually exists.
    You can do this by stepping through the code and checking the value or by using a msgbox to display it or using a debug.print to display it.

    Edit: After a second look I see that path is empty when it gets here so that part of the if statement would not be executed which means that is not the problem but also means it should not be there.

  6. #6
    Junior Member MernaSly07's Avatar
    Join Date
    Oct 12
    Location
    indonesia
    Posts
    27

    Red face Re: Runtime error 76 "path not found"

    Quote Originally Posted by Doogle View Post
    The implication of the error is that the path: 'C:\Daftar Karyawan\2012\OCTOBER\' doesn't exist
    what i should do ? hmm tell me...

  7. #7
    Junior Member MernaSly07's Avatar
    Join Date
    Oct 12
    Location
    indonesia
    Posts
    27

    Re: Runtime error 76 "path not found"

    if i remove & "\" , it will error ..
    how ?
    hmm confused

  8. #8
    Junior Member MernaSly07's Avatar
    Join Date
    Oct 12
    Location
    indonesia
    Posts
    27

    Re: Runtime error 76 "path not found"

    Quote Originally Posted by DataMiser View Post
    I am surprised no one pointed this out
    Code:
    If Right(GBLpathFile, 1) = "\" Then
                path = path & "\" & "Daftar Karyawan" & "\" & Year(Date) & "\" & UCase(Format(Date, "MMMM")) & "\" & .FileTitle
    Here if your path ends in "\" your are adding another "\" to it which would make it invalid

    Of course I do not know what is in your path variaible so that may or may not be the problem but is surely incorrect. You need to remove the part in red.

    You should also check to see what the path holds after it is built and then see if that path actually exists.
    You can do this by stepping through the code and checking the value or by using a msgbox to display it or using a debug.print to display it.

    Edit: After a second look I see that path is empty when it gets here so that part of the if statement would not be executed which means that is not the problem but also means it should not be there.

    if i remove & "\" , it will error ..
    how ?
    hmm confused

  9. #9
    Junior Member MernaSly07's Avatar
    Join Date
    Oct 12
    Location
    indonesia
    Posts
    27

    Re: Runtime error 76 "path not found"

    Name:  path not found.png
Views: 445
Size:  53.6 KB this problem help me

  10. #10
    PowerPoster
    Join Date
    Feb 12
    Location
    West Virginia
    Posts
    4,957

    Re: Runtime error 76 "path not found"

    if i remove & "\" , it will error ..
    how ?
    hmm confused
    Look at what you have here
    Code:
            If Right(GBLpathFile, 1) = "\" Then
                path = path & "\" & "Daftar Karyawan" & "\" & Year(Date) & "\" & UCase(Format(Date, "MMMM")) & "\" & .FileTitle
            Else
                path = path & "\" & "Daftar Karyawan" & "\" & Year(Date) & "\" & UCase(Format(Date, "MMMM")) & "\" & .FileTitle
            End If
    There is no reason to even have an If test here as it will do the same thing no matter what the test result so 4 of those lines are useless or one of them is in error.
    That said it is not the source of your error just a problem with the coding.

    The error is telling you that whatever is in the path at the time is not valid. Look at what comes up in the message box then check to see if that folder exists on the drive where it is looking.

  11. #11
    Junior Member MernaSly07's Avatar
    Join Date
    Oct 12
    Location
    indonesia
    Posts
    27

    Re: Runtime error 76 "path not found"

    Quote Originally Posted by MernaSly07 View Post
    if i remove & "\" , it will error ..
    how ?
    hmm confused
    Quote Originally Posted by DataMiser View Post
    Look at what you have here
    Code:
            If Right(GBLpathFile, 1) = "\" Then
                path = path & "\" & "Daftar Karyawan" & "\" & Year(Date) & "\" & UCase(Format(Date, "MMMM")) & "\" & .FileTitle
            Else
                path = path & "\" & "Daftar Karyawan" & "\" & Year(Date) & "\" & UCase(Format(Date, "MMMM")) & "\" & .FileTitle
            End If
    There is no reason to even have an If test here as it will do the same thing no matter what the test result so 4 of those lines are useless or one of them is in error.
    That said it is not the source of your error just a problem with the coding.

    The error is telling you that whatever is in the path at the time is not valid. Look at what comes up in the message box then check to see if that folder exists on the drive where it is looking.
    folder doesn't exists.
    the message error "path not found"
    but i had been added some coding. but still the same

  12. #12
    Web developer Nightwalker83's Avatar
    Join Date
    Dec 01
    Location
    Adelaide, Australia
    Posts
    9,731

    Re: Runtime error 76 "path not found"

    You could created the directory if it does not exist by doing:

    vb Code:
    1. mkdir("Daftar Karyawan")
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    Please consider giving me some rep points if I help you a lot.
    DON'T BUMP YOUR POSTS!!! Links to my code examples can now be found on my website: My websites
    Please rate my post if you find it helpful!
    Technology is a dangerous thing in the hands of an idiot! I am that idiot.

  13. #13
    Frenzied Member SamOscarBrown's Avatar
    Join Date
    Aug 12
    Location
    NC, USA
    Posts
    1,554

    Re: Runtime error 76 "path not found"

    Look--before you run that line of code "path =.....", put in a msgbox call followers by that "path =...." statement. Read the messagebox and compare that file path with the actual path of the file on your computer- I'd bet they don't match, especially if there ARE two side-by-side back slashes. Compare them closely and then change your code to reflect the EXACT path ( and file name if applicable) that you really want.
    You can step through your code with debug, line by line and see what is going on, or you can use msgboxes or labels or text boxes or lists or other controls to check your code as you run it . Also, if you learn to use on error goto, it can help a lot by trapping the error number and description.

    Good luck

    Pls excuse typing errors- on iPhone

  14. #14
    Junior Member MernaSly07's Avatar
    Join Date
    Oct 12
    Location
    indonesia
    Posts
    27

    Re: Runtime error 76 "path not found"

    Quote Originally Posted by MernaSly07 View Post
    folder doesn't exists.
    the message error "path not found"
    but i had been added some coding. but still the same
    success

  15. #15
    Junior Member MernaSly07's Avatar
    Join Date
    Oct 12
    Location
    indonesia
    Posts
    27

    Re: Runtime error 76 "path not found"

    Quote Originally Posted by Nightwalker83 View Post
    You could created the directory if it does not exist by doing:

    vb Code:
    1. mkdir("Daftar Karyawan")
    i had been create folder

  16. #16
    Junior Member MernaSly07's Avatar
    Join Date
    Oct 12
    Location
    indonesia
    Posts
    27

    Re: Runtime error 76 "path not found"

    Quote Originally Posted by SamOscarBrown View Post
    Look--before you run that line of code "path =.....", put in a msgbox call followers by that "path =...." statement. Read the messagebox and compare that file path with the actual path of the file on your computer- I'd bet they don't match, especially if there ARE two side-by-side back slashes. Compare them closely and then change your code to reflect the EXACT path ( and file name if applicable) that you really want.
    You can step through your code with debug, line by line and see what is going on, or you can use msgboxes or labels or text boxes or lists or other controls to check your code as you run it . Also, if you learn to use on error goto, it can help a lot by trapping the error number and description.

    Good luck

    Pls excuse typing errors- on iPhone
    Ya thanks. but now had been successfull

  17. #17
    Junior Member MernaSly07's Avatar
    Join Date
    Oct 12
    Location
    indonesia
    Posts
    27

    Re: Runtime error 76 "path not found"

    how to added picture from vb to sql server ?

  18. #18
    PowerPoster
    Join Date
    Jul 06
    Location
    Maldon, Essex. UK
    Posts
    5,144

    Re: Runtime error 76 "path not found"

    Quote Originally Posted by DataMiser View Post
    I am surprised no one pointed this out
    Code:
    If Right(GBLpathFile, 1) = "\" Then
                path = path & "\" & "Daftar Karyawan" & "\" & Year(Date) & "\" & UCase(Format(Date, "MMMM")) & "\" & .FileTitle
    I did notice that, but if you look you'll see that path is Dim'd at the top of the code so iit's value will be null. Also, GBLpathFile is the Initial Directory for the Common Dialog, so I'm not sure why OP is using that. EDIT: @DM just noticed your Edit !

    @OP: For future reference, the full path to a file must exist before you can create the file. You may run into difficulties in January next year unless you've already created the necessary sub-folders.

    There's a handy API: 'MakeSureDirectoryPathExists' you can use which, as the name implies, will create the full path if one doesn't already exist.

    You could use it like this:
    Code:
    Option Explicit
    
    Private Declare Function MakeSureDirectoryPathExists Lib "imagehlp.dll" _
                (ByVal lpPath As String) As Long
                
    Private Sub Form_Load()
    MakeSureDirectoryPathExists "C:\" & "Daftar Karyawan" & _
                    "\" & Year(Date) & _
                    "\" & UCase(Format(Date, "MMMM")) & _
                    "\"
    End Sub
    BTW You should close this Thread as resolved and start another one for your latest question as it's an entirely different subject. (You should also search the Forums as there's quite a few threads on the subject)
    Last edited by Doogle; Oct 11th, 2012 at 02:28 AM.

  19. #19
    Junior Member MernaSly07's Avatar
    Join Date
    Oct 12
    Location
    indonesia
    Posts
    27

    Talking Re: Runtime error 76 "path not found"

    Quote Originally Posted by Doogle View Post
    I did notice that, but if you look you'll see that path is Dim'd at the top of the code so iit's value will be null. Also, GBLpathFile is the Initial Directory for the Common Dialog, so I'm not sure why OP is using that. EDIT: @DM just noticed your Edit !

    @OP: For future reference, the full path to a file must exist before you can create the file. You may run into difficulties in January next year unless you've already created the necessary sub-folders.

    There's a handy API: 'MakeSureDirectoryPathExists' you can use which, as the name implies, will create the full path if one doesn't already exist.

    You could use it like this:
    Code:
    Option Explicit
    
    Private Declare Function MakeSureDirectoryPathExists Lib "imagehlp.dll" _
                (ByVal lpPath As String) As Long
                
    Private Sub Form_Load()
    MakeSureDirectoryPathExists "C:\" & "Daftar Karyawan" & _
                    "\" & Year(Date) & _
                    "\" & UCase(Format(Date, "MMMM")) & _
                    "\"
    End Sub
    BTW You should close this Thread as resolved and start another one for your latest question as it's an entirely different subject. (You should also search the Forums as there's quite a few threads on the subject)
    i want ask you .. may you
    hmm where i should write function convert data in sql server?
    hmm maybe in function - scalar valued functions, isn't it ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •