|
-
Oct 8th, 2012, 09:54 PM
#1
Thread Starter
Junior Member
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..
-
Oct 8th, 2012, 09:56 PM
#2
Thread Starter
Junior Member
Re: Runtime error 76 "path not found"
FileCopy strPATHGAMBAR, path this is error
please help me
-
Oct 9th, 2012, 12:59 AM
#3
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 ...
-
Oct 9th, 2012, 03:02 AM
#4
Re: Runtime error 76 "path not found"
The implication of the error is that the path: 'C:\Daftar Karyawan\2012\OCTOBER\' doesn't exist
-
Oct 9th, 2012, 06:14 AM
#5
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.
-
Oct 10th, 2012, 07:53 PM
#6
Thread Starter
Junior Member
Re: Runtime error 76 "path not found"
 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...
-
Oct 10th, 2012, 08:00 PM
#7
Thread Starter
Junior Member
Re: Runtime error 76 "path not found"
if i remove & "\" , it will error ..
how ?
hmm confused
-
Oct 10th, 2012, 08:01 PM
#8
Thread Starter
Junior Member
Re: Runtime error 76 "path not found"
 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
-
Oct 10th, 2012, 08:09 PM
#9
Thread Starter
Junior Member
Re: Runtime error 76 "path not found"
this problem help me
-
Oct 10th, 2012, 09:08 PM
#10
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.
-
Oct 10th, 2012, 10:36 PM
#11
Thread Starter
Junior Member
Re: Runtime error 76 "path not found"
 Originally Posted by MernaSly07
if i remove & "\" , it will error ..
how ?
hmm confused
 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
-
Oct 10th, 2012, 11:16 PM
#12
Re: Runtime error 76 "path not found"
You could created the directory if it does not exist by doing:
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Oct 10th, 2012, 11:29 PM
#13
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
-
Oct 10th, 2012, 11:35 PM
#14
Thread Starter
Junior Member
Re: Runtime error 76 "path not found"
 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
-
Oct 10th, 2012, 11:36 PM
#15
Thread Starter
Junior Member
Re: Runtime error 76 "path not found"
 Originally Posted by Nightwalker83
You could created the directory if it does not exist by doing:
i had been create folder
-
Oct 10th, 2012, 11:38 PM
#16
Thread Starter
Junior Member
Re: Runtime error 76 "path not found"
 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
-
Oct 11th, 2012, 01:57 AM
#17
Thread Starter
Junior Member
Re: Runtime error 76 "path not found"
how to added picture from vb to sql server ?
-
Oct 11th, 2012, 02:24 AM
#18
Re: Runtime error 76 "path not found"
 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)
Last edited by Doogle; Oct 11th, 2012 at 02:28 AM.
-
Oct 11th, 2012, 02:32 AM
#19
Thread Starter
Junior Member
Re: Runtime error 76 "path not found"
 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 ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|