Ron_dK
Cool bop aficionado
- Local time
- Today, 18:59
- Joined
- Sep 5, 2002
- Messages
- 2,141
Hi all,
I have a number of queries in which criteria is set for certain periodes , e.g.
"between #01/01/2008" and #04/01/2008".
In stead of changing these dates manually ( in the Qry) , I would like to change this thru VBA or using code.
Example of Query :
This is what I have made in VB, ( with Thanks to WayneRyan) but this doesn't work :
I would appreciate any pointers on this.
I have a number of queries in which criteria is set for certain periodes , e.g.
"between #01/01/2008" and #04/01/2008".
In stead of changing these dates manually ( in the Qry) , I would like to change this thru VBA or using code.
Example of Query :
Code:
SELECT TbRequest.Country, TbInput.[Conducted]
FROM TbRequest LEFT JOIN TbInput ON TbRequest.[Req-ID] = TbInput.[Req id]
WHERE (((TbInput.[Conducted]) Between #1/1/2008# And #12/31/2008#))
ORDER BY TbInput.[Conducted];
This is what I have made in VB, ( with Thanks to WayneRyan) but this doesn't work :
Code:
Sub Qry2009Update()
Dim ctl As Control
DoCmd.OpenQuery "QryStat", acDesign
For Each ctl In Query("QryStat").Controls
With ctl
Select Case .ControlType
Case acTextBox
ctl.ControlSource = Replace(ctl.ControlSource, "/2008#", "/2009#")
End Select
End With
Next ctl
DoCmd.Close acQuery, "QryStat", acSaveYes
End Sub
I would appreciate any pointers on this.