Filter Report Macro Button Requires Two Clicks

AccessNoob98

New Member
Joined
Jan 2, 2014
Messages
2
Hello

I currently have a form (call it Parent) with a subform (call it Child) and report in that subform. The subform contains a combo box and a command button that people can use to filter the report. For some reason, the value in the combo box is not being used to filter the report until after the command button is already clicked once. I am using a macro with the ApplyFilter command. This works fine when I try it on the Child form by itself, but when I put the Child into Parent as a subform and then modify the reference in the macro, it now requires that I click the command button twice.

For instance, if the user selects "Business" in the combo box and clicks the command button, I want the report to filter so only records that have "Business" in that specific field will appear. However when the user does this, the report filters so that no records appear (because the combo box was empty by default). Now if the user presses the button again without doing anything else, the "Business" records appear. Now if the user changes the combo box to anything else, it again requires two clicks. For some reason the value the user is selecting in the combo box is not recognized until after the command button is already pressed once. This also happens if I use the OnChange event in the combo box instead of using the command button, the "Business" records will not appear until after the user changes the combo box from "Business" to something else. The OnDirty event does not work as any Macro I put in that event is cleared when I save and close the form.

Does anyone have an idea of why this is happening?

Thanks.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
welcome to the forum

please post the code for the button click handler so one of us can have a look at it
 
Upvote 0
welcome to the forum

please post the code for the button click handler so one of us can have a look at it

The code is built from the Macro builder

It references a table (Services), an ID number in that table (ServicesID), a report (ServicesReport) that was built from the table, the parent form (Main), the child form (ServicesForm), and a combo box on the child form (cbServices)


ApplyFilter

Filter Name (not filled in)
Where Condition =[Services]![ServicesID]=[Forms]![Main]![ServicesForm].[Form]![cbServices]
Control Name ServicesReport

I used this site as a reference for the syntax of the where condition: Forms: Refer to Form and Subform properties and controls

As mentioned earlier, this macro works fine (the report filters on one click) if I do not have the child form (ServicesForm) embedded in the main form (Main) and in that instance the where condition in the ApplyFilter macro reads Where Condition =[Services]![ServicesID]=[Forms]![ServicesForm]![cbServices]
 
Upvote 0

Forum statistics

Threads
1,216,077
Messages
6,128,673
Members
449,463
Latest member
Jojomen56

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top