troubleshooting Question

Convert complicated SQL codes together to VBA to be used as record source for a report

Avatar of SteveL13
SteveL13Flag for United States of America asked on
Microsoft Access
7 Comments2 Solutions81 ViewsLast Modified:
I am using two queries like:

SELECT tblCategoriesAndSubCategories.ElevatorReportSortOrder, tblCategoryInfo.Category, tblCategoryInfo.SubCategory, tblCategoryInfo.Description, tblCategoryInfo.JobNo
FROM tblCategoryInfo INNER JOIN tblCategoriesAndSubCategories ON (tblCategoryInfo.Category = tblCategoriesAndSubCategories.Category) AND (tblCategoryInfo.SubCategory = tblCategoriesAndSubCategories.SubCategory)
WHERE (((tblCategoryInfo.Description) Not Like "NA") AND ((tblCategoryInfo.JobNo)=[Forms]![frmReportSelector]![cboSelectJob2]) AND ((tblCategoryInfo.ElevatorReport)=True)) OR (((tblCategoryInfo.Description) Is Null) AND ((tblCategoryInfo.JobNo)=[Forms]![frmReportSelector]![cboSelectJob2]) AND ((tblCategoryInfo.ElevatorReport)=True))
ORDER BY tblCategoriesAndSubCategories.ElevatorReportSortOrder;

And

SELECT tblCategoriesAndSubCategories.ElevatorReportSortOrder, tblCategoryInfo.Category, tblCategoryInfo.SubCategory, tblCategoryInfo.Description, tblCategoryInfo.JobNo
FROM tblCategoryInfo INNER JOIN tblCategoriesAndSubCategories ON (tblCategoryInfo.Category = tblCategoriesAndSubCategories.Category) AND (tblCategoryInfo.SubCategory = tblCategoriesAndSubCategories.SubCategory)
WHERE (((tblCategoryInfo.Description) Not Like "NA") AND ((tblCategoryInfo.JobNo)=[Forms]![frmReportSelector]![cboSelectJob3]) AND ((tblCategoryInfo.ElevatorReport)=True)) OR (((tblCategoryInfo.Description) Is Null) AND ((tblCategoryInfo.JobNo)=[Forms]![frmReportSelector]![cboSelectJob3]) AND ((tblCategoryInfo.ElevatorReport)=True))
ORDER BY tblCategoriesAndSubCategories.ElevatorReportSortOrder;

and then am combining them together in a final query with:

SELECT qryElevatorReportDetailColumn1.ElevatorReportSortOrder AS SortOrder, qryElevatorReportDetailColumn1.SubCategory AS Job1SubCategory, qryElevatorReportDetailColumn1.Description AS Job1Description, qryElevatorReportDetailColumn1.JobNo AS Job1JobN, qryElevatorReportDetailColumn2.SubCategory AS Job2SubCategory, qryElevatorReportDetailColumn2.Description AS Job2Description, qryElevatorReportDetailColumn2.JobNo AS Job2JobN
FROM qryElevatorReportDetailColumn1 INNER JOIN qryElevatorReportDetailColumn2 ON qryElevatorReportDetailColumn1.SubCategory = qryElevatorReportDetailColumn2.SubCategory;

How can I convert all of this to VBA as the record source for the report?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 7 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 2 Answers and 7 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