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.
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.