I have a function which generates sub-form data and although it looks extremely complicated it works perfectly. The function is called in the on-load of the sub-form and can therefore be modified and the sub-form re-queried to update the data.
What I want to do is add a checkbox to the main form that allows me to modify the sort order and for the life of me cannot even get close. I am thinking something along the lines of:
Any help would be greatly appreciated.
Code:
Public Function scanresults()
'Populate results according to criteria on main form
Dim scandata As String
scandata = "SELECT qryScans.Scanned, " & _
"qryScans.ID, qryScans.Blade, qryScans.Engine, " & _
"qryScans.Part, qryScans.Hours, qryScans.Cycles, " & _
"qryScans.Result, qryScans.Tank, qryScans.Operator, " & _
"qryScans.Details, qryScans.Co, MRO.MRO " & _
"FROM qryScans INNER JOIN MRO ON qryScans.Co = MRO.ID " & _
"WHERE (qryScans.Scanned BETWEEN Forms!frmMain!tStartDate And Forms!frmMain!tEndDate)" & _
"AND qryScans.Blade LIKE '*' &(Forms!frmMain!tBlade) & '*'" & _
"AND qryScans.Engine LIKE '*' &(Forms!frmMain!tEngine) & '*'" & _
"AND qryScans.Part LIKE '*' &(Forms!frmMain!tPart) & '*'" & _
"AND qryScans.Hours >= (Forms!frmMain!tHours)" & _
"AND qryScans.Cycles >= (Forms!frmMain!tCycles)" & _
"AND qryScans.Co LIKE (Forms!frmMain!cboMRO)" & _
"AND qryScans.Tank LIKE '*' &(Forms!frmMain!tSystem) & '*'" & _
"AND qryScans.Operator LIKE '*' &(Forms!frmMain!tUser) & '*'" & _
"AND qryScans.Result LIKE '*' &(Forms!frmMain!tStatus) & '*'" & _
"ORDER BY qryScans.Scanned;"
Forms!FRmMain!test.Form.RecordSource = scandata
End Function
What I want to do is add a checkbox to the main form that allows me to modify the sort order and for the life of me cannot even get close. I am thinking something along the lines of:
Code:
"ORDER BY IIf forms!frmMain!checkbox.value = -1, qryScans.Scanned IIf forms!frmMain!checkbox.value <> -1, qryScans.ID ;"
Any help would be greatly appreciated.