I am trying to do some error trapping on a form that creates a new database file.
The user enters the name in the control on the form and presses the cmd button to create a new file. I want to error trap for a filename that already exists.
My code as follows
dim fsoFileSearch as FileSearch
Dim intResponse as integer
Set fsoFileSearch = Application.Filesearch
With fsoFileSearch
.newsearch
.lookin = GetDBDir()
.filename = me.txtWellID & ".mdb."
.execute
if .foundfiles > 0 then
intResponse = msgbox("File Already Exists", vbOKCancel + vbExclamation + vbDefaultButton1)
if (intResponse = 0) then
forms!frmCreateWell!txtWellID.setfocus
End if
End if
End with
I want the cursor to return tot he text box and clear it for txtWellID rentry. Now it just creates a file with no name and .mdb extension.
Thanks for your help.
BusMgr
The user enters the name in the control on the form and presses the cmd button to create a new file. I want to error trap for a filename that already exists.
My code as follows
dim fsoFileSearch as FileSearch
Dim intResponse as integer
Set fsoFileSearch = Application.Filesearch
With fsoFileSearch
.newsearch
.lookin = GetDBDir()
.filename = me.txtWellID & ".mdb."
.execute
if .foundfiles > 0 then
intResponse = msgbox("File Already Exists", vbOKCancel + vbExclamation + vbDefaultButton1)
if (intResponse = 0) then
forms!frmCreateWell!txtWellID.setfocus
End if
End if
End with
I want the cursor to return tot he text box and clear it for txtWellID rentry. Now it just creates a file with no name and .mdb extension.
Thanks for your help.
BusMgr