Private Sub Export_Click()
Dim ctl As Control
Dim sFilter As String
Dim sContName As String
sFilter = ""
sFilter = "WHERE TblTcAOG.[ATA2DIGIT] = 36"
'For Each ctl In Controls
' If ctl.Tag = "ATA" Then
' sContName = Right(ctl.Name, 2)
'Debug.Print sContName
'Once you have this working listing each control now interrogate the value
' If ctl.Value = True Then
' sFilter = sFilter & "," & sContName
' End If
' End If
'Next ctl
'sFilter = sFilter & ")"
'Debug.Print sFilter
Dim dbsCurrent As Database
Dim SQL_Name As QueryDef
Dim SQL_Output As String
Dim dStart As String
Dim dEnd As String
Set dbsCurrent = CurrentDb
Set SQL_Name = dbsCurrent.QueryDefs("qry_AOGreport_criteria")
dStart = "#" & Format([Forms]![FrmRptCriteriaAOG]![Beg_date_txt], "mm/dd/yyyy") & "#"
dEnd = "#" & Format([Forms]![FrmRptCriteriaAOG]![End_Date_txt], "mm/dd/yyyy") & "#"
SQL_Output = "SELECT DISTINCTROW TblTcAOG.[ID] " & _
"FROM tblactype INNER JOIN (TblAcrft INNER JOIN (TblTcAOG INNER JOIN TblAirports ON TblTcAOG.STN = TblAirports.STN) ON TblAcrft.Reg = TblTcAOG.REG) ON tblactype.actypeid = TblAcrft.ModelLink "
Set dbsCurrent = Nothing
Set SQL_Name = Nothing
End Sub