I have a query, "adhocComplete" that has criteria ">=[Forms]![frmAdhoc].[Date] And <=[Forms]![frmAdhoc].[Date2]" for the field [30DayDue].
Is there a way of removing the criteria from the query by unchecking a checkbox [Check62] on the form [frmAdhoc] and re-adding the criteria if the checkbox is check?
I found the below code and think it is the way I am trying to go, but can't get it to work.
Thanks in advance
Is there a way of removing the criteria from the query by unchecking a checkbox [Check62] on the form [frmAdhoc] and re-adding the criteria if the checkbox is check?
I found the below code and think it is the way I am trying to go, but can't get it to work.
Code:
Dim qdf As DAO.QueryDef
Dim qdfOLD As String
Set qdf = CurrentDb.QueryDefs("Query1")
With qdf
qdfOLD = .SQL
.SQL = Replace(.SQL, "ProjectRef='P4'", "ProjectRef='P5'")
' Code to do stuff with SQL-string/query
.SQL = qdfOLD ' Reset SQL to old setting
End With
Set qdf = Nothing
Thanks in advance
Last edited: