Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2004
    Location
    Tulsa, OK
    Posts
    50

    Unanswered: Using Macro to SetValue a Form Filter Property

    The title says it all. In detail:

    My form's recordsource is a table w/ 195 records. The form shows one record's information at a time (using nav buttons). I have a ComboBox on the form w/ no ControlSource, but a built in list of selections that matches one of the fields from the table. This is the "Filter Selection Combo".

    I have put a macro in the Change Event of the Combo. I want the macro to change the form's Filter property (SetValueItem "Form![FormName].Filter", SetValueExpression "What I want the filter to be") , then apply the filter. Unfortunately, I keep getting an error (see attachments). I'd like to know what I'm doing wrong, and/or a better way to accomplish what I'm trying to do. Thanks in advance.

    Stace
    Attached Thumbnails Attached Thumbnails DROP DOWN SEARCH 1.jpg   DROP DOWN SEARCH 2.jpg  
    Thanks in advance or hope this helps.

  2. #2
    Join Date
    Feb 2004
    Location
    CT,USA
    Posts
    250
    Cause of error is that the macro is external to the form code. You need to put your filter code in the after update event of your combo box. In design view of the form, click on combo box, then event tab then go to 'after update' pull down event procedure, hit the "..." to the right---> put your code here.

  3. #3
    Join Date
    Mar 2004
    Location
    Tulsa, OK
    Posts
    50
    What is the code counterpart to the Macro SetValue?
    Thanks in advance or hope this helps.

  4. #4
    Join Date
    Feb 2004
    Location
    CT,USA
    Posts
    250
    Just put the equation in the arguments (see your 2nd jpg) as it appears there, and place it as described above.

  5. #5
    Join Date
    Mar 2004
    Location
    Tulsa, OK
    Posts
    50
    Here's my new error, and the Combo entry.
    Attached Thumbnails Attached Thumbnails DROP DOWN SEARCH 3.jpg   DROP DOWN SEARCH 4.jpg  
    Thanks in advance or hope this helps.

  6. #6
    Join Date
    Mar 2004
    Location
    Tulsa, OK
    Posts
    50
    Almost there . . . got the code right (pic 5), but what happens now is this:

    The user makes a selection from the "Division Combo", aka Combo100 (See pic 6), and up pops a parameter dialog box in which you have to type in the selection you just made to make it work. If I can get it to work on selection from the Combo without the dialog box, I'm finished.

    BTW, thanks. Your advice has really helped.
    Attached Thumbnails Attached Thumbnails DROP DOWN SEARCH 5.jpg   DROP DOWN SEARCH 6.jpg  
    Thanks in advance or hope this helps.

  7. #7
    Join Date
    Mar 2004
    Location
    Tulsa, OK
    Posts
    50
    Question #1: Why would my form not show the FilterOn property in its list?

    Question #2: Why would this parameter dialog box show up given the previous posts? (Obviously somethings not correct)

    Thanks in advance.

    Stace
    Thanks in advance or hope this helps.

  8. #8
    Join Date
    Mar 2004
    Location
    Tulsa, OK
    Posts
    50

    Why doesn't the parameter get passed to the applied filter?

    OK - boiled it down to a simple question . . .

    If I have this in the "after update" event of the combobox:

    Private Sub Combo100_AfterUpdate()
    [Forms]![INTERACTIVE SEARCH].Filter = "[SWITCH INFORMATION]![DIVISION]=[Combo100]"
    [Forms]![INTERACTIVE SEARCH].FilterOn = "True"
    End Sub

    Then why doesn't the parameter (i.e. the Combobox selection) get passed to the applied filter? (I'm still getting a Parameter Box)
    Thanks in advance or hope this helps.

Posting Permissions

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