Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to check if table exists

178 views
Skip to first unread message

Pawel Wrobel

unread,
Feb 4, 2005, 8:59:29 AM2/4/05
to
Hi!
I have a folowing situation - in my Access database I have a table that is
linked with SPS. I put some data into this table to present it no SPS. The
thing is that when I have no connection with SPS then I get ugly VB error
message (table is readonly or does not exist)

What I would like to do is return nice message like "SPS is not connected"
is case of such event. How to do this?

One way is to catch the error event and fire a function on error. The other
is check if table exists before running the update. But how to do this?

Thnx
Pawel


Salad

unread,
Feb 4, 2005, 10:25:15 AM2/4/05
to
Pawel Wrobel wrote:

Sub xx()
Dim tdf As TableDef
On Error GoTo 0
On Error Resume Next
Set tdf = CurrentDb.TableDefs("NonExistTableName")
MsgBox Err.Number ''will be 3265
On Error GoTo 0
On Error Resume Next
Set tdf = CurrentDb.TableDefs("ExistingTableName")
MsgBox Err.Number 'will be 0
Set tdf = Nothing
End Sub

jimfo...@compumarc.com

unread,
Feb 4, 2005, 2:34:53 PM2/4/05
to

I got this from this NG:

Public Function IsTable(strTable As String) As Boolean
Dim tdf As TableDef

IsTable = False
For Each tdf In CurrentDb.TableDefs
If tdf.Name = strTable Then
IsTable = True
Exit For
End If
Next tdf
End Function

James A. Fortune

0 new messages