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..
Re: Runtime error 76 "path not found"
FileCopy strPATHGAMBAR, path this is error
please help me
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"
Re: Runtime error 76 "path not found"
The implication of the error is that the path: 'C:\Daftar Karyawan\2012\OCTOBER\' doesn't exist
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.
Re: Runtime error 76 "path not found"
Quote:
Originally Posted by
Doogle
The implication of the error is that the path: 'C:\Daftar Karyawan\2012\OCTOBER\' doesn't exist
what i should do ? hmm tell me...
Re: Runtime error 76 "path not found"
if i remove & "\" , it will error ..
how ?
hmm confused
Re: Runtime error 76 "path not found"
Quote:
Originally Posted by
DataMiser
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
1 Attachment(s)
Re: Runtime error 76 "path not found"
Attachment 92249 this problem help me
Re: Runtime error 76 "path not found"
Quote:
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.
Re: Runtime error 76 "path not found"
Quote:
Originally Posted by
MernaSly07
if i remove & "\" , it will error ..
how ?
hmm confused
Quote:
Originally Posted by
DataMiser
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
Re: Runtime error 76 "path not found"
You could created the directory if it does not exist by doing:
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
Re: Runtime error 76 "path not found"
Quote:
Originally Posted by
MernaSly07
folder doesn't exists.
the message error "path not found"
but i had been added some coding. but still the same
success
Re: Runtime error 76 "path not found"
Quote:
Originally Posted by
Nightwalker83
You could created the directory if it does not exist by doing:
i had been create folder :D
Re: Runtime error 76 "path not found"
Quote:
Originally Posted by
SamOscarBrown
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
Re: Runtime error 76 "path not found"
how to added picture from vb to sql server ?
Re: Runtime error 76 "path not found"
Quote:
Originally Posted by
DataMiser
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)
Re: Runtime error 76 "path not found"
Quote:
Originally Posted by
Doogle
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 ?