473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to check if table exists

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
2 13163
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jonathan | last post by:
I am looking for a simple way to check if a database table exists. I keep getting advice to use "Try.. Catch" and other error handling methods, but I obviously don't want to have to display an...
3
by: DottingTheNet | last post by:
i promise no more silly questions after this but how do i check if a table exists?? it is my understanding that the exists can only be used in the where clause of the query. i just want s'thing...
2
by: adam | last post by:
hello What query shoul I send to SQL serwer ( in transact SQL language ) to check does some database exist on serwer ? It similar to problem "does some table exist in database" - resolve to it...
2
by: Chris Windsor | last post by:
I hope the following describe what I'm trying to do: I have created a tool to be used by product analysts when studying different cell phone designs. Part of the tool is a set of 11 forms on a...
10
by: Geoff Jones | last post by:
Hi I'm trying to drop a table by using: Dim cmd As New OleDbCommand("DROP TABLE IF EXISTS books", myconnection) cmd.ExecuteNonQuery() but I get a syntax error: "Syntax error in DROP TABLE...
2
by: RLN | last post by:
Re: Access 2003 I have code to check to see if a table exists. There are several other tables (tblQ12, tblQ13, etc) that do already exist & this code runs fine; msgbox says the value returned is...
16
by: Brian Tkatch | last post by:
Is there a way to check the order in which SET INTEGRITY needs to be applied? This would be for a script with a dynamic list of TABLEs. B.
0
by: bharathreddy | last post by:
This article will explain you how to check weather a column already exists in a table before you add the column to the table using alter command. Using the system tables...
4
by: qwedster | last post by:
Howdy folks! I am using stored procedure to see if a value exists in database table and return 0 if exists or else -1, in the following SQL queries. However how to check if a value (that is...
2
by: qwedster | last post by:
Folk! How to programattically check if null value exists in database table (using stored procedure)? I know it's possble in the Query Analyzer (see last SQL query batch statements)? But how...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.