I want to replace Query1.Period parameter "May 2018" with "Jun 2018".
SQL:
SELECT DISTINCTROW Query1.Period, Query1.Portfolio_1
FROM Query1
WHERE (((Query1.Period)="May 2018"))
ORDER BY Query1.Portfolio_2, Query1.Department, Query1.Position_NO;
VBA code attempt:
Private Sub newChangePeriodCriteria_Click()
Dim qdf As DAO.QueryDef
Dim qdfOLD As String
Set qdf = CurrentDb.QueryDefs("Query1_Mth")
With qdf
qdf.SQL = sqlString
.SQL = Replace(.SQL, "Period='May 2018'", "Period='Jun 2018'")
' Code to do stuff with SQL-string/query
' .SQL = qdfOLD ' Reset SQL to old setting
qdfOLD = .SQL
' DoCmd.RunSQL (Replace("Period='May 2018'", "Period='Jun 2018'"))
End With
Set qdf = Nothing
End Sub