• Between dates in parameter query (Access 2K)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Between dates in parameter query (Access 2K)

    Author
    Topic
    #405761

    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

    Viewing 1 reply thread
    Author
    Replies
    • #836282

      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]

    • #836283

      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]

    Viewing 1 reply thread
    Reply To: Between dates in parameter query (Access 2K)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: