Creating a Function - error accessing file message is displayed

  • Thread starter Thread starter Pele
  • Start date Start date
P

Pele

I had created a database but while trying to create a new
Function on the Modules Tab, I usually receive a message
saying "Error accessing fle, network connection may have
been lost". While troubleshooting this, I noticed that my
VBE and Database were not in sync and I was adviced to
create a blank database and reimport my objects from the
corrupted database. I have done this and the VBE is now in
sync with the database but the error message still persist
anytime I try to create this funtion. Below is the
function I was trying to create. Can somebody help me with
what I need to do to get rid of this error message.

Pele

===============FUNCTION==================================

Option Compare Database

Public Function fnDoesTableExist(Tablename) As Boolean
Dim tmp As Boolean, tbldef As Variant
tmp = False

For Each tbldef In CurrentDb.TableDefs
If tbldef.Name = Tablename Then
tmp = True
End If

Next
fnDoesTableExist = tmp
End Function
 
Back
Top