Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2002
    Posts
    36

    Unanswered: passing parameter values to query from code

    I have a query as my recordsource in a report. My query has 2 paramters (begDt and endDt) which apply to the where clause. Using VBA in say a report header event, how can i automatically pass values to those paramters without prompting the user to enter values?


    I've tried (with set and without):

    currentdb.querydefs(me.recordsource).paramters(0) = date()

    where parameter(0) is begDt, and parameter(1) is endDt. No luck.

    Any clues?

    Thx,

    Jim

  2. #2
    Join Date
    Jun 2002
    Location
    Vienna, VA
    Posts
    53
    make sure you have a reference to DAO.

    Dim qdf as DAO.QueryDef

    set qdf = CurrentDB.Querydefs("Name of Query")
    qdf![Parameter Name] = SomeValue
    qdf![OtherParameterName] = SomeOtherValue


    You might have to refresh the report.

    Hope this helps.

    Leah

  3. #3
    Join Date
    Jul 2002
    Posts
    36
    Thx Leah.

    That works perfectly for setting the values. (I was not declaring my qry var as a DAO object.) But I am still prompted for the paramter values when i run the report. Any suggestions?

    Jim

Posting Permissions

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