Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error coding around Runtime Error 3011

Status
Not open for further replies.

jalge2

Technical User
Feb 5, 2003
105
US
I have a command button that imports .txt files into a database. The text files show all of the activity in the building. If there is no activity, then no text file is created.

We run this command button to import that data into a table in a database. The problem is, when there is no text file, then the database error's out. I'm trying to error code it to resume next and go through that. What I have is

Private Sub Import_New_File_Click()
On Error GoTo Import_New_File_Click:

After this is all of the code which I'm not going to include because of length. And at the bottom is

Import_New_File_Click:
MsgBox Err.Description = [3011]
Resume Import_New_File_Click

End Sub

Obviously this is wrong, but I'm not sure what I'm doing wrong. Can someone help?

Jason Alge
Jason.M.Alge@lowes.com

'There are three kinds of people: Those who can count and those who can't'
 
Hi,

Try using the Dir function to check if the txt file exists instead of waiting for the error

Check_FilePath = Dir(file_path)

Check_FilePath = True if it exists

Otherwise you can check for the error number in your error handler as follows

if err.number = 3031
'Resume
else
msgbox("Error")
end if

 
Check_FilePath = True if it exists
No: = file_path if it exists, "" otherwise.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top