Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 6th, 2007, 03:36 PM
Authorized User
 
Join Date: Apr 2007
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default Check if Object Exists in the Database

I want to try to check if an object exists in the database before I do the command to delete it. Any help on how to do that?

At this point I am stuck at the following point:

If dbs("Feed_CslLiveJobs") .:(.. Exists? = True Then
        DoCmd.DeleteObject acQuery, "Feed_CslLiveJobs"
End If


Thanks,
Coby

 
Old June 7th, 2007, 12:05 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Here is the lazy man's way of doing this:

Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentData
For Each obj In dbs.AllQueries
    If obj.Name = "Feed_CslLiveJobs" Then
           DoCmd.DeleteObject acQuery, "Feed_CslLiveJobs"
    End If
Next obj

Did that help?


mmcdonal
 
Old June 7th, 2007, 02:56 PM
Authorized User
 
Join Date: Apr 2007
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You've helped me before and you've helped me once again!

Thanks a million.

Coby.








Similar Threads
Thread Thread Starter Forum Replies Last Post
Check if Div Layer/Object Exists lian_a Javascript How-To 5 April 23rd, 2008 01:53 AM
check whether COM object exists EddyT C# 0 June 15th, 2007 04:10 AM
How to check if exists BEFORE the Insert rtr1900 Classic ASP Databases 0 December 20th, 2006 07:04 AM
check first to see if the file exists crmpicco Classic ASP Professional 2 December 1st, 2005 12:34 PM
How to check if connection already exists Ciarano VB How-To 3 March 9th, 2004 10:24 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.