The following VBA Function can be used to produce a list of all the queries within a given MS Access database.
'--------------------------------------------------------------------------------------- ' Procedure : ListDbQrys ' Author : CARDA Consultants Inc. ' Website : http://www.cardaconsultants.com ' Purpose : Returns a ';' separated string containing the names of all the queries ' within the database (use Split() to convert the string to an array) ' Copyright : The following may be altered and reused as you wish so long as the ' copyright notice is left unchanged (including Author, Website and ' Copyright). It may not be sold/resold or reposted on other sites (links ' back to this site are allowed). ' ' Revision History: ' Rev Date(yyyy/mm/dd) Description ' ************************************************************************************** ' 1 2007-Nov Initial Release '--------------------------------------------------------------------------------------- Function ListDbQrys() As String On Error GoTo Error_Handler Dim DbO As AccessObject Dim DbCD As Object Dim Qrys As String Set DbCD = Application.CurrentData For Each DbO In DbCD.AllQueries Qrys = Qrys & ";" & DbO.Name Next DbO Qrys = Right(Qrys, Len(Qrys) - 1) 'Truncate initial ; ListDbQrys = Qrys Error_Handler_Exit: Set DbCD = Nothing Set DbO = Nothing Exit Function Error_Handler: MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf & "Error Number: " & _ Err.Number & vbCrLf & "Error Source: ListDbQrys" & vbCrLf & "Error Description: " & _ Err.Description, vbCritical, "An Error has Occured!" Resume Error_Handler_Exit End Function

Thursday, June 10th, 2010, 8:14 pm | 

