Results 1 to 2 of 2
2004-06-04, 08:55 #1
- Join Date
- Oct 2001
- Newport, Gwent, Wales
- Thanked 0 Times in 0 Posts
Between dates in parameter query (Access 2K)
I'm trying to use a query with VBA code, as such I know I have to set the parameters as QueryDef and have the same parameter in the Query > Parameters menu option. This works great for most things, but I'm struggling on how to use the Between #date1# and #date2# type of parameter. This is slightly more difficult as I'm referring to text boxes on forms, so it's actually Between [forms]![formname]![control1] and [forms]![formname]![control2]. This is not, apparently, acceptable to the VBA editor when entered into the .Parameters("................") section of my code.
What should I be doing? Is it even possible to use the between #date# and #date# as a VBA QueryDef parameter?
2004-06-04, 10:27 #2
- Join Date
- Mar 2002
- Thanked 30 Times in 30 Posts
Re: Between dates in parameter query (Access 2K)
You don't set "Between ... And ..." as parameter, but the individual dates:
' QueryDef object.
Dim qdf As DAO.QueryDef
Set qdf = CurrentDb.QueryDefs("qrySomething")
' Set parameters.
qdf.Parameters("[Forms]![frmInput]![StartDate]") = Forms![frmInput]![StartDate]
qdf.Parameters("[Forms]![frmInput]![EndDate]") = Forms![frmInput]![EndDate]