Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Oct 2001
    Location
    Newport, Gwent, Wales
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Between dates in parameter query (Access 2K)

    Hello again

    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?

    Thanks

    Ian

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 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]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •