Get request type property in VBA

Is there a way to identify the type of request in VBA (i.e. add a request, select a request, delete a request, make a request in a table)? I am creating a function with a string parameter (query). He will have to check if the request exists, and then its action will depend on the type of request.

+4
source share
1 answer

Examine the query property QueryDef.Type. It returns a value from the DAO QueryDefTypeEnum Enumeration . (You can also check this listing in Object Browser from the VB editor instead of searching it online.)

, , VBA.

? DAO.QueryDefTypeEnum.dbQSelect
 0 
? CurrentDb.QueryDefs("qrySelect").Type
 0 
? CurrentDb.QueryDefs("qrySelect").Type = dbQSelect
True
? DAO.QueryDefTypeEnum.dbQDelete
 32 
? CurrentDb.QueryDefs("qryDelete").Type = dbQDelete
True
' qryBogus does not exist, so the next statement throws
' Error 3265: Item not found in this collection. 
? CurrentDb.QueryDefs("qryBogus").Type
+3

All Articles