troubleshooting Question

Creating cascading queries in vba

Avatar of rogerdjr
rogerdjrFlag for United States of America asked on
VBA* Access
5 Comments1 Solution45 ViewsLast Modified:
I created two queries in Access

The first is

SELECT CASp_StandardChecklistIndexTbl.CheckListIndexRecId, CASp_StandardChecklistIndexTbl.CheckListTitle, CASp_StandardChecklistRefCodeSectTbl.CheckListRedId, CASp_StandardChecklistTbl.CheckListIndexRecId, CASp_StandardChecklistTbl.CheckListItemSeqNo, CASp_StandardChecklistTbl.CheckListItemBriefDescr, CASp_StandardChecklistRefCodeSectTbl.CheckListRefCodeSectRefRecNo, CASp_StandardChecklistRefCodeSectTbl.CodeSectRefRecNo, CASp_CodeSectListTbl.Code, CASp_CodeSectListTbl.CodeSect, CASp_CodeSectListTbl.CodeSubSectId, CASp_StandardChecklistRefCodeSectTbl.DateEntered, CASp_StandardChecklistRefCodeSectTbl.DateRevised, CASp_StandardChecklistRefCodeSectTbl.RevisedByUserId
FROM CASp_StandardChecklistIndexTbl INNER JOIN ((CASp_StandardChecklistRefCodeSectTbl LEFT JOIN CASp_CodeSectListTbl ON CASp_StandardChecklistRefCodeSectTbl.CodeSectRefRecNo = CASp_CodeSectListTbl.CodeSectRefRecNo) INNER JOIN CASp_StandardChecklistTbl ON CASp_StandardChecklistRefCodeSectTbl.CheckListRedId = CASp_StandardChecklistTbl.CheckListRecId) ON CASp_StandardChecklistIndexTbl.CheckListIndexRecId = CASp_StandardChecklistTbl.CheckListIndexRecId
ORDER BY CASp_StandardChecklistIndexTbl.CheckListIndexRecId, CASp_StandardChecklistTbl.CheckListItemSeqNo;

The second is a cross tab query based on the first

TRANSFORM Count([_CheckListCodeRefListQry].CodeSectRefRecNo) AS CountOfCodeSectRefRecNo
SELECT [_CheckListCodeRefListQry].CASp_StandardChecklistIndexTbl.CheckListIndexRecId, [_CheckListCodeRefListQry].CheckListTitle, [_CheckListCodeRefListQry].CheckListRedId, [_CheckListCodeRefListQry].CheckListItemSeqNo, [_CheckListCodeRefListQry].CheckListItemBriefDescr, Count([_CheckListCodeRefListQry].CodeSectRefRecNo) AS [Total Of CodeSectRefRecNo]
FROM _CheckListCodeRefListQry
GROUP BY [_CheckListCodeRefListQry].CASp_StandardChecklistIndexTbl.CheckListIndexRecId, [_CheckListCodeRefListQry].CheckListTitle, [_CheckListCodeRefListQry].CheckListRedId, [_CheckListCodeRefListQry].CheckListItemSeqNo, [_CheckListCodeRefListQry].CheckListItemBriefDescr
PIVOT [_CheckListCodeRefListQry].Code;

I want to use vba to create these queries to make a report - is ther a way to create the cascading queries in vba so I don';t have to rely on the saved queries?
ASKER CERTIFIED SOLUTION
Mark Edwards
Chief Technology Officer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros