Check Table Name?

  • Thread starter Thread starter Gary
  • Start date Start date
G

Gary

Does anyone know of a way to check a table name? I do a
lot of work at home and transfer databases back-and-forth
so I have to rename tables for testing (don't have access
to the live data so I import the data tables for testing).

Before I run a macro, I want to check the file name and
ensure that I'm pointing to the correct table before
continuing.

Any help is welcome. Thank you in advance.

Gary
 
Gary,

Been there, done it time and again... sure I can help, but
not quite sure what exactly you're after: name of table in
your db, or existence of source file of linked table?

Former:
Function check_table_exists(tblnam As String)
For Each tbl In CurrentDb().TableDefs
If tbl.Name = tblnam Then
check_table_exists = True
Exit Function
End If
Next
check_table_exists = False
End Function

Latter:
Function check_file_exists(fnam As String)
If Dir(fnam) <> "" Then
check_file_exists = True
Else
check_file_exists = False
End If
End Function
fnam must contain the full path.

In the latter case, you would probably also need tp change
links; I've got code for that too, if you need it.

HTH,
Nikos
 
Back
Top