Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Sep 2002
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Output with parameter (2000)

    Hello,

    I have the following code:
    Code:
    	Dim stDocName As String
    
    	stDocName = "QueryRegistExcel"
    	DoCmd.OutputTo acQuery, stDocName, acFormatXLS
    QueryRegistExcel has a parameter to limit its output to a certain conference. Can I write code so that the parameter is automatically equal to this form's "Me!FlyInIDNum".

    This code acts like it is suppossed to except in that one area.

    Thank you
    Frank Luke

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Output with parameter (2000)

    I don't know the name of the form you are dealing with, but a general method for using the value of a control on a form as the criteria for a field is

    Forms![MyFormName]![FlyInIDNum]
    Wendell

  3. #3
    New Lounger
    Join Date
    Sep 2002
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Output with parameter (2000)

    Great, but how do I set the query's parameter definitions from the code? I have a method to do so, but it won't work with the DoCmd below. When I run the code, I get a popup box asking me to enter the parameter by hand. Is there any way to automate that process sticking pretty close to the code I already have?

    [almost working code]
    Dim stDocName As String

    stDocName = "QueryRegistExcel"
    DoCmd.OutputTo acQuery, stDocName, acFormatXLS
    [/almost working code]

    ...or does the code need to be rewritten?

    Frank Luke

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Output with parameter (2000)

    In the original query, you had a parameter in the Criteria row, something like [Enter ID]. So when you ran the query, an input dialog box was displayed with the text between the brackets (Enter ID in the example) as prompt.

    In the design of the query, you must replace this parameter with Forms![frmFormName]![FlyInIDNum], where frmFormName must be replaced by the exact name of the form, and FlyInIDNum by the exact name of the control on the form that contains the restricting value. The spelling must conform exactly - if the form name or control name is off by only one character, Access won't recognize the expression and pop up the input dialog box.

  5. #5
    New Lounger
    Join Date
    Sep 2002
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Output with parameter (2000)

    Perfect! My thanks to both of you! Wendel for telling me what to do, and Hans for filling in what I was missing! <img src=/S/bravo.gif border=0 alt=bravo width=16 height=30>

    Frank Luke

Posting Permissions

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