Error - Creating Report from combo-box on Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MiniMike13
    New Member
    • Nov 2011
    • 2

    Error - Creating Report from combo-box on Form

    Hi, need some help please! Here is a quick description of what I'm trying to achieve:

    I have an Access 2010 database where I can produce a Report based on my various "products".

    It currently lists all products and the relevant info to that product I have added. I have also created a Form with a drop down box of all my "products".

    What I want to do is, click on a button next to the drop down box in my Form and select this "product" only to show in my Report. I have used the following to do this:

    Code:
    Private Sub Report_Click()
    
    DoCmd.OpenReport "xxTotSum", acViewPreview, , "[Article No#]=" & Me![ArticleNoBox], acWindowClose
    
    End Sub
    However, when I then try to 'click' my button, I only get the "Enter Parameter Value" box. I hate this box! Any ideas of what I need to do? Important note, my VBA and Access knowledge is very small - currently learning by doing!
    [imgnothumb]http://bytes.com/attachments/attachment/5588d1320164198/error.jpg[/imgnothumb]
    Attached Files
    Last edited by NeoPa; Nov 2 '11, 01:53 AM. Reason: Added mandatory [CODE] tags for you and showed pic
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    Don't forget to use the mandatory code tags around your code.

    What I usually do in this situation is to base the report off of a query and the query has the criteria for the ProductID based on the combo box selection. You would then use the after update event of the combo box to open the report like this:

    Code:
    DoCmd.OpenReport "xxTotSum", acViewPreview
    This should give the results that you are looking for.

    If you need help with the query, just let me know. I'll need to know the field names to be included in the report.

    Comment

    • MiniMike13
      New Member
      • Nov 2011
      • 2

      #3
      Hi Seth

      Thanks for the response. I've got my code like you've suggested, by I still get the "Enter Parameter Value" box.

      I think the query and report are correct because these already work. All I want to do is rather than have a report which lists all of my "Products", I want to select one from the drop box on my Form and then press the button to select and produce the Report.

      Do you think my query is maybe wrong then?!

      Comment

      • Seth Schrock
        Recognized Expert Specialist
        • Dec 2010
        • 2965

        #4
        That would seem to be the only option left. If you could post the SQL code for your query and the name of the combo box and form it is on, I'll check it out.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32654

          #5
          Originally posted by MiniMike
          MiniMike:
          However, when I then try to 'click' my button, I only get the "Enter Parameter Value" box
          The prompt in the box would be more helpful than the title that's common to all such prompts.

          This generally indicates you've mis-spelled or mistyped something. What that is we can't know without your telling us the contents of the box.

          You can find more on your general task at Example Filtering on a Form.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32654

            #6
            Originally posted by MiniMike
            MiniMike:
            Do you think my query is maybe wrong then?!
            After what you've posted in #3 then Yes. That's very likely.

            We would still benefit from knowing the exact contents of the prompt box though.

            Comment

            Working...