How to identify the type of query?

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

Hi folk,

Is is possible to identify the type of query via vba? For example: select
query, delete query, update query?

Thanks in advance.

Tim.
 
Hi Douglas,

Could you give me an example? I tired the site but it did not make sense to
me. I am looking for something like I provide the name of query and then it
returns the type of query.

Thanks,
Tim.
 
Try this:

Function TypeOfQuery(QueryName As String) As String
On Error Resume Next

Dim qdfcurr As DAO.QueryDef

Set qdfcurr = CurrentDb.QueryDefs(QueryName)
If Err.Number <> 0 Then
TypeOfQuery = QueryName & " doesn't exist."
Else
Select Case qdfcurr.Type
Case dbQAction
TypeOfQuery = "Action"
Case dbQAppend
TypeOfQuery = "Append"
Case dbQCompound
TypeOfQuery = "Compound"
Case dbQCrosstab
TypeOfQuery = "Crosstab"
Case dbQDDL
TypeOfQuery = "Data-definition"
Case dbQDelete
TypeOfQuery = "Delete"
Case dbQMakeTable
TypeOfQuery = "Make-table"
Case dbQProcedure
TypeOfQuery = "Procedure"
Case dbQSelect
TypeOfQuery = "Select"
Case dbQSetOperation
TypeOfQuery = "Union"
Case dbQSPTBulk
TypeOfQuery = "Pass-through (no records returned)"
Case dbQSQLPassThrough
TypeOfQuery = "Pass-through"
Case dbQUpdate
TypeOfQuery = "Update"
Case Else
TypeOfQuery = "Unknown"
End Select
End If

End Function
 
Hi Douglas,

The code works great. It is exactly what I am looking for.

Thank you very much.

Tim.
 
Back
Top