Results 1 to 2 of 2

Thread: if exhists?

  1. #1
    Join Date
    Aug 2002
    Charlotte NC

    Unanswered: if exhists?

    is there a conditional logic that states:
    if database object.queryname EXHISTS
    then delete database object.queryname
    end if

    if so what is the syntax for it or what key word do i search under in the help/web?
    Regards Jim

  2. #2
    Join Date
    Apr 2002
    Hi Jim,

    Suggest you have a look at the Document object in the Container object.
    You keywords will be something like:

    Sub DeleteYourQuery()

    Dim wrkStandaard As Workspace
    Dim ThisDB As Database
    Dim ctr As Container, doc As Document

    Set wrkStandaard = DBEngine.Workspaces(0)
    Set ThisDB = CurrentDb
    Set ctr = ThisDB.Containers!Tables 'Note this, Access sees a Query as a table

    For Each doc In ctr.Documents
    MsgBox doc.Name 'you will get system tables as well
    If doc.Name = "YourQuery" Then
    DoCmd.DeleteObject acQuery, doc.Name
    End If

    Next doc

    End Sub


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts