Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

querydef

Status
Not open for further replies.

jplum

Programmer
Joined
May 23, 2002
Messages
25
Location
US
I have some code that creates a querydef, runs an export with the newly created query and then deletes the querydef.

What I'd like to do is check to see if the querydef already exists before I try and create it, but I cannot figure out the code for this.

Thanks!
 
A simple way is to use DCount in VBA, as follows:

Code:
If DCount("*", "MSysObjects", "Type=5 AND Name='PutYourQueryDefNameHere') > 0 Then
    Msgbox "Querydef exists.", vbInformation
Else
    Msgbox "Querydef doesn't exist.", vbInformation
End If
[pc2]
 
Thanks so much. That worked great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top