I am passing a SQL string to a Pass Thru query (SQL Server Backend). When the User selects a report from [cmbReports] they will also have the Option to select a payor from [cmbFscRptCat2Grouping]. Basically I would like for the user to be able to run the report with or without a selection from combo box [cmbFscRptCat2Grouping].
The below code works as long as a selection is made in [cmbFscRptCat2Grouping]
The below code works as long as a selection is made in [cmbFscRptCat2Grouping]
Code:
Select Case cmbReports
Case "Unresponded"
SQL = "SELECT *"
SQL = SQL + " FROM Group_" & cmbGroups & "_ATB_Daily_Grouped"
SQL = SQL + " LEFT JOIN Dictionaries.dbo.Tbl_Fsc_RptCat2_Grouped ON [FSC Reporting Category 2] = [FSC_REPORT_CATEGORY_2]"
SQL = SQL + "WHERE ([REJECTION_1] IS NULL AND Grouping = '" & cmbFscRptCat2Grouping & "')"
db.QueryDefs("Reports").Connect = "ODBC;DRIVER=SQL Server Native Client 10.0;SERVER=MWNSQLD16;Trusted_Connection=YES;Database=ATB;"
db.QueryDefs("Reports").SQL = SQL
DoCmd.OpenQuery "Reports"