Specific Form Filtering Techniques

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dalan

    #1

    Specific Form Filtering Techniques

    Okay, I have worked on this and then some, but cannot seem to crack
    it. So if someone can straighten my code out, or suggest a new
    approach, then I'm all ears.

    Here goes: I have two tables - one (tblReports) with all of the fields
    appearing on a report selection form (frmReports). The other one
    (tblGroup) is only use for the eight group types that I'm trying to
    use as a filter. The tblGroup is hooked to the tblReports Group field
    (rptType). When I open the combo box (cboEight) on the form, I see the
    8 groups listed, and also in the list box (lboList), I see "all
    groups" of the reports listed (rptName).

    Now, what I want to do is simply have a little code on the OnOpen
    event of the report selection form that enables the filter (if used -
    no filtering if not) to only show the related reports under the
    selected group. So far - no go. Here is one piece of code that I used,
    but it triggered Error 2448 - can't assign a value to this object. Of
    course, I got a couple of different errors after tweaking it. The
    code: Me.Filter = "rptType = " & Form_frmReports .cboEight.Value
    Me.FilterOn = True
    I also used rptName in lieu of rptType - same error message. What do
    you think?

    Thanks in advance for showing me "where" I missed it. Dalan
  • Mike Pace

    #2
    Re: Specific Form Filtering Techniques

    Dalan,

    After the form is open, when the user chooses a group from the combo
    box cboEight, dynamically change the RecordSource property for the
    form to an sql statement that will select only reports for the group
    chosen. Do this in the On Click event for the combo box.

    Code Sample:

    Private Sub cboEight_Click( )

    If Not IsNull(Me.cboEi ght) Then
    Me.RecordSource = "SELECT * FROM tblReports WHERE [rptType] =
    '" & Me.cboEight & "'"
    End If

    End Sub

    Changing the RecordSource property will cause the recordset underlying
    the form to be requeried automatically. I hope I understood your
    question correctly and I hope my response helps.

    Mike Pace
    M. L. Pace Computer Consulting
    Mobile, Alabama

    other@safe-mail.net (Dalan) wrote in message news:<504f21f6. 0309100345.744d e322@posting.go ogle.com>...[color=blue]
    > Okay, I have worked on this and then some, but cannot seem to crack
    > it. So if someone can straighten my code out, or suggest a new
    > approach, then I'm all ears.
    >
    > Here goes: I have two tables - one (tblReports) with all of the fields
    > appearing on a report selection form (frmReports). The other one
    > (tblGroup) is only use for the eight group types that I'm trying to
    > use as a filter. The tblGroup is hooked to the tblReports Group field
    > (rptType). When I open the combo box (cboEight) on the form, I see the
    > 8 groups listed, and also in the list box (lboList), I see "all
    > groups" of the reports listed (rptName).
    >
    > Now, what I want to do is simply have a little code on the OnOpen
    > event of the report selection form that enables the filter (if used -
    > no filtering if not) to only show the related reports under the
    > selected group. So far - no go. Here is one piece of code that I used,
    > but it triggered Error 2448 - can't assign a value to this object. Of
    > course, I got a couple of different errors after tweaking it. The
    > code: Me.Filter = "rptType = " & Form_frmReports .cboEight.Value
    > Me.FilterOn = True
    > I also used rptName in lieu of rptType - same error message. What do
    > you think?
    >
    > Thanks in advance for showing me "where" I missed it. Dalan[/color]

    Comment

    • DannyY

      #3
      Re: Specific Form Filtering Techniques


      Use the Load event instead of Open



      Good luck,



      Dan





      Originally posted by Dalan
      [color=blue]
      > Okay, I have worked on this and then some, but cannot seem to crack[/color]
      [color=blue]
      > it. So if someone can straighten my code out, or suggest a new[/color]
      [color=blue]
      > approach, then I'm all ears.[/color]
      [color=blue]
      >[/color]
      [color=blue]
      > Here goes: I have two tables - one (tblReports) with all of the fields[/color]
      [color=blue]
      > appearing on a report selection form (frmReports). The other one[/color]
      [color=blue]
      > (tblGroup) is only use for the eight group types that I'm trying to[/color]
      [color=blue]
      > use as a filter. The tblGroup is hooked to the tblReports Group field[/color]
      [color=blue]
      > (rptType). When I open the combo box (cboEight) on the form, I see the[/color]
      [color=blue]
      > 8 groups listed, and also in the list box (lboList), I see "all[/color]
      [color=blue]
      > groups" of the reports listed (rptName).[/color]
      [color=blue]
      >[/color]
      [color=blue]
      > Now, what I want to do is simply have a little code on the OnOpen[/color]
      [color=blue]
      > event of the report selection form that enables the filter (if used -[/color]
      [color=blue]
      > no filtering if not) to only show the related reports under the[/color]
      [color=blue]
      > selected group. So far - no go. Here is one piece of code that I used,[/color]
      [color=blue]
      > but it triggered Error 2448 - can't assign a value to this object. Of[/color]
      [color=blue]
      > course, I got a couple of different errors after tweaking it. The[/color]
      [color=blue]
      > code: Me.Filter = "rptType = " & Form_frmReports .cboEight.Value[/color]
      [color=blue]
      > Me.FilterOn = True[/color]
      [color=blue]
      > I also used rptName in lieu of rptType - same error message. What do[/color]
      [color=blue]
      > you think?[/color]
      [color=blue]
      >[/color]

      Thanks in advance for showing me "where" I missed it. Dalan



      --
      Posted via http://dbforums.com

      Comment

      Working...