view not in CurrentData.AllViews

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to use the following code to determine whether I need to drop an
old view prior to creating a new one. Can anyone tell me why it fails?

Application.RefreshDatabaseWindow
DoEvents
Exists = False
For Each obj In CurrentData.AllViews
If obj.Name = strObjectName Then
Exists = True
Exit Function
End If
Next obj

This routine may return Exists = False even when the view has actually been
created by earlier code.

The first two lines do not always work. Somethimes, I have to press F5 to
make the old view appear in the Database Window, before the routine can
detect it (which tells the VBA code that called it to drop the view).
Sometimes, I can repeat the execution of these two lines in Break Mode, and
the routine will work.

I'm now having to resort to error-trapping, which seems heavy-handed to me.
 
Thanks, Peter. I knew there was something like that.

But, for future reference, can you tell me why

Application.RefreshDatabaseWindow
DoEvents

isn't sufficient? Would it have worked if I'd invoked a dummy query on the
view before I tested for its existence?

-- Allen
 
Don't work with ADP's myself.
however: The Beuty of the Information_Schema views are that they are
cross-platform
MSSQL, Oracle MySQL, ...

A shame they don't cover indexes though

Pieter
 
Back
Top