Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Simple Form (2000)

    I am trying to create a form with a combo box that is connected to a query that has 1 field - Product description. I want to be able to select a product from this list and have a subform show all the records with the same Product description. I put a subform on the form and link with the Product description but when I select a different product the subform doesn't do anything. What am I missing?

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

    Re: Simple Form (2000)

    Create an After Update event procedure for the combo box to requery the subform:

    Private Sub cmbProduct_AfterUpdate()
    Me.Subformname.Requery
    End Sub

    where cmbProduct is the name of the combo box and Subformname is the name of the subform as a control on the main form (this is not necessarily the same as the name it has in the database window).

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Simple Form (2000)

    It still doesn't work. I am baffled as to why.

  4. #4
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Simple Form (2000)

    I got it to work. Now, is there a way to make a report of the results. When someone chooses a product description and the subform displays the results, I would like to have a command button that would print what is displayed in the subform. How would I do this?

    I created a report from the query that is behind the subform. I put a command button on my form that print previews the report. Now I have to get the report to print what is on the subform. Any help would be greatly appreciated - Thanks

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

    Re: Simple Form (2000)

    The On Click procedure for the command button uses DoCmd.OpenReport to preview the report. You can specify the WhereCondition argument of OpenReport to filter the records in the report:

    Private Sub cmdPreview_Click()
    DoCmd.OpenReport "rptProducts", acViewPreview, , "[Product Description] = " & Chr(34) & Me.cmbProduct & Chr(34)
    End Sub

    where cmdPreview is the name of the command button, rptProducts is the name of the report, Product Description is the name of the field to filter on and cmbProduct is the name of the combo box.

Posting Permissions

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