473,385 Members | 1,877 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,385 software developers and data experts.

Checking for existance of a view

I was wondering what the VBA code would be to test to see if a view
already exists, or how to overwrite a view if it already exists.

Also, how would I do the same for a regular table?

Database: Access 97
Connection: ADO 2.0

Please reply to my email aswell as the group if possible.

-Thanks!

--
Chad Reid - Programmer
Strategic Tech Solutions
cr*************@on.aibn.com
Office: (905) 623-5693

Nov 12 '05 #1
1 2820
Hi,

In order to get information about tables and views from a database using
ADO, you need to use ADOX, which is the ADO extension for Data Definition
Language and Security.

However I user only ADO 2.5 and 2.6, so I don't know if ADOX is available
for ADO 2.0 (although, it might be)

But there are few drawbacks with this approach (at least if you want to
modify a view)

From MSDN help:

"Important Although it is possible to create and modify a stored query in
an Access database by using Microsoft ActiveX® Data Objects Extensions for
Data Definition Language and Security (ADOX), if you do so your query won't
be visible in the Access Database window or in any other part of the Access
user interface-for example, you can't set the RecordSource property of a
form to a query created with ADOX, nor can you import a query created with
ADOX into another database. However, you can still run stored queries
created by using ADOX from ADO code. This is so because the Microsoft Jet
4.0 database engine can run in two modes: one mode that supports the same
Jet SQL commands used in previous versions of Access, a new mode that
supports new Jet SQL commands and syntax that are more compliant with the
ANSI SQL-92 standard"

A better approach will be to use querydefs collections of DAO.database
object to change the SQL statement for the query (which is DAO equivalent
for a ADO view)

In ADOX, you can use the following code to enumerate all tables and view:

Dim catDB As ADOX.Catalog

Set catDB = New ADOX.Catalog
' Open the catalog.
catDB.ActiveConnection = Access.CurrentProject.Connection ' or any
connection string, if you want to check a different database

Dim tb As ADOX.Table
Dim vw As ADOX.View

For Each tb In catDB.Tables
Debug.Print tb.Name
Next

For Each vw In catDB.Views
Debug.Print vw.Name
Next

However, ADOX Tables collection store also the name of the queries.

HTH,
Regards,
Bogdan Zamfir

_______________________________
Independent consultant

"Chad Reid" <cr*************@on.aibn.com> wrote in message
news:Pi*************************************@cyber delia.homeunix.org...
I was wondering what the VBA code would be to test to see if a view
already exists, or how to overwrite a view if it already exists.

Also, how would I do the same for a regular table?

Database: Access 97
Connection: ADO 2.0

Please reply to my email aswell as the group if possible.

-Thanks!

--
Chad Reid - Programmer
Strategic Tech Solutions
cr*************@on.aibn.com
Office: (905) 623-5693

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Paris_Sucks | last post by:
I'm trying to redirect when testing for certain condidtions as shown below. When the conditions are ture, it redirects, but still goes ahead and processes the sql query. What am I doing wrong??? ...
2
by: William Kossack | last post by:
I'm trying to write a program in cold fusion to check the existance of fields and data types according to requirements I was looking at the syscolumns table for some of this information but I've...
1
by: Xeno Campanoli | last post by:
I'm having a hard time checking existence of windows. The only thing I found on this is page 224 of Rhino. Why is there no function to check this? Is there a publication on this part of the...
4
by: Lambuz | last post by:
Is there any way to check the existance of a window by the name ? I'm using this code: window.open("http://www.google.com",'targetWin1') If I open a window using previous code without getting...
4
by: lyndon hughey | last post by:
I'm having a problem setting the testing for the existance of a nodes outerxml property. Below I try to test for the existance before I access the property, but I receive a null exception error. ...
5
by: A.M | last post by:
Hi, To check if QueryString contains a key I compaire it with null like this code: if (Request.QueryString!=null) { Label1.Text= Request.QueryString; } else
2
by: tshad | last post by:
I was looking at different ways of doing the same thing and at the moment was looking at the use of "is" and "=", as I have at times found that I will do something like if something = 0 and...
6
by: Andy B | last post by:
How do you check to see if a certain folder exists? I also need to know how to check for the existance of a certain sql server database table.
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.