Quote:
quote:Originally posted by rmsmit
Some guy came up with this and it works.
----------------------------------------------------------
Function VindQuery(Naam As String) As Boolean
Dim Db As dao.database
Dim QueryDefinitie As QueryDef
Set Db = CurrentDb
For Each QueryDefinitie In Db.QueryDefs
If QueryDefinitie.Name = Naam Then VindQuery = True
Next
End Function
------------------------------------------------------------
|
it should have been
----------------------------------------------------------
If QueryDefinitie.Name = Naam Then
VindQuery = True
exit for
endif
----------------------------------------------------------
because there is no need to continue the loop if the query is found.
But it is much faster to do:
----------------------------------------------------------
Function QueryExists(Naam As String) As Boolean
on error resume next
QueryExists = not (CurrentDb.QueryDefs(Naam) is nothing)
end function
----------------------------------------------------------
Marco