By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,098 Members | 989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,098 IT Pros & Developers. It's quick & easy.

How to check if table exists

P: n/a
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
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Pawel Wrobel wrote:
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

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
Nov 13 '05 #2

P: n/a
Pawel Wrobel wrote:
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


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

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.