Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2004
    Posts
    83

    Unanswered: Running a Report based on Form Data

    I've got a small form that has one combo box on it. The user is to choose an item and hit "Go". A report should then popup based on the item chosen in the combo.
    I've done this for opening a query, but I can't seem to figure out the how to open the report based on the data.

    Here is my Logic...
    1) Create a Query with a Criteria feild containg [Form]![MyForm]![cboItem]

    2)Create a report and set the Record Source to the query I just made

    3) In the code of the "Go" Button I added "DoCmd.OpenReport ("MyReport")"

    The result is that no report is displayed, instead it prints off the report to my PCs default printer without even showing me the report or prompting for me to choose a printer.

    So it technically works, I think I'm just missing something.
    Any ideas?

  2. #2
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557

    Yes it is working perfectly.

    It works perfectly... you just need to as a few things beyond the form name to make it preview for you instead of print. (Print is the default option when opening a report).


    Code:
    DoCmd.OpenReport ("MyReport", acViewPreview, , , acWindowNormal)
    add that stuff to the end and you will be good to go

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  3. #3
    Join Date
    Mar 2004
    Posts
    83
    Ah ha, that makes sence, I didn't think I turned on a print option.

    Are you sure about that command? it keeps giving me a "Compile Error: Expected ="

  4. #4
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557

    Hmm...

    That is how I open all of my reports. I dont use the ( )'s though.

    Does it give you the option to debug? If so then debug and copy and paste the whole function associated and I will see if I can find the error.

    If it doesnt give you that option just give me all the code for the form and I will see what I can find.

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  5. #5
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Originally posted by High_D
    Ah ha, that makes sence, I didn't think I turned on a print option.

    Are you sure about that command? it keeps giving me a "Compile Error: Expected ="
    That is how I open all of my reports. I dont use the ( )'s though.

    Does it give you the option to debug? If so then debug and copy and paste the whole function associated and I will see if I can find the error.

    If it doesnt give you that option just give me all the code for the form and I will see what I can find.

    JS
    Remember guys that with VB/VBA when you use parens that VB/VBA expects an assignment to a variable ... With not parens there is no expectation of a return value ...

  6. #6
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    Okay cool I didnt know that. I just figured that out with the answer you gave to my question a few minutes ago. So I was correct in just asking him to drop the parens.

    Thanks,
    JS

    Originally posted by M Owen
    Remember guys that with VB/VBA when you use parens that VB/VBA expects an assignment to a variable ... With not parens there is no expectation of a return value ...
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

Posting Permissions

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