Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.
On the email form When one of the attach buttons is clicked the Windows browser opens if cancel is pressed instead of selecting a file and then the Send Via Outlook button is clicked I get this error:
Run-time error '-2147024893 (80070003)': Path does not exist. Verify path is correct.
In the sample database, EmailSeminar-NEW, I got the same error.
I tried adding On Error Resume Next but now I get this error:
Run-time error '-2147352567 (80020009)': Array index out of bounds.
I'm out of my league with this, any help would be appreciated.
And yeah, cancel will generate that error. I don't think I trapped it. A simple On Error... will fix that.
Amanda McDonaldOP 13 months ago
I tried adding On Error and got a new error.
Run-time error '-2147352567 (80020009)':
Array index out of bounds.
Am I putting the on error in the wrong place?
Amanda McDonaldOP 13 months ago
Kevin Robertson 13 months ago
I just downloaded the database file and it worked perfectly for me without any errors.
Have you made any changes to Richard's code?
Also the On Error Resume Next would need to be in the PickFile sub in the Module (which is already in place).
Did you click the Debug button to see which line was actually throwing the error?
Amanda McDonaldOP 13 months ago
No, I haven't changed any of the code in his db. Yes, I debugged, I tried to post screenshots of everything but some of them didn't post. I'll try to explain it better.
Everything works fine...unless I click either of the attach buttons on the email form <I>and then</I> click <B>Cancel</B> in the file select window without selecting a file. <I>And then</I> click the Send Via Outlook button on the email form.
That gives me this error:
Run-time error '-2147024893 (80070003)':
Path does not exist. Verify path is correct.
Which debugs to one of these two lines, depending on which attach button was canceled.
OMsg.Attachments.Add (MsgAttach1)
OMsg.Attachments.Add (MsgAttach2)
That is why I tried adding the On Error for those blocks of code. But with the On Error where I have it in the picture above I get this error.
Run-time error '-2147352567 (80020009)':
Array index out of bounds.
It does the same thing in my DB. And it still does it in the class DB when I change the folder path.
The only thing different is I took the Attach Folder field off my form and instead put the path in the PickFile code.
In both DB's I tried using the path "Z:\Attachments\" instead of "Z:\Attachments" and I still got the same error.
I learn by doing, so I don't usually open the class DBs. I build my own DBs along with you in your seminars.
I ran into the error when testing my DB. I re-wound, re-watched, and went over everything multiple times.
Couldn't figure it out, decided to open the class DB to compare the code, sure it was something simple.
But ran into the error in the class DB too.
Well there's your problem. Now trace it back and find out where it's getting it's value from. MsgBox it each step of the way. Make sure you have the field name spelled right on the form. Check what PickFile is returning, etc.
Kevin Robertson 13 months ago
Amanda,
Modify the block of code as below (also checking for an empty string):
If Not IsNull(MsgAttach1) And MsgAttach1 <> "" Then
If Dir(MsgAttach1) = "" Then
MsgBox "Attachment 1 does not exist"
Else
OMsg.Attachments.Add (MsgAttach1)
End If
End If
If Not IsNull(MsgAttach2) And MsgAttach2 <> "" Then
If Dir(MsgAttach2) = "" Then
MsgBox "Attachment 2 does not exist"
Else
OMsg.Attachments.Add (MsgAttach2)
End If
End If
Amanda McDonaldOP 13 months ago
I am missing something, I thought it should be empty since I am clicking cancel instead of selecting a file. What should populate in the MsgBox when I hit cancel?
If you hit cancel that should return an empty string, which means you haven't picked a file. The system WILL give you an error then if you don't trap it and exit.
Amanda McDonaldOP 13 months ago
Thank you Kevin that worked like a charm! Thanks for sticking with me Richard.
It didn't click for me that the cancel button was returning an empty string until Keven posted his code and said to check for one.
I feel like I learned this lesson the hard way, and drug ya all through the mud with me.
Thank you!!!
That's what you're here for: to learn this stuff, and honestly, the best way to learn is to struggle with something for a while because now you won't make that mistake again.
Sami Shamma 13 months ago
Good for you, Amanda. You stuck with it until you got it.
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Email Seminar Lessons.
The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.