Filter Subform from Parent Form

I have a subform inside a parent form. The subform shows up as a datasheet inside the parent form. I have two comboboxes in the parent form. When the user chooses a value from the combobox the subform should get filtered according to those two values.

The following is the code I used. It opens up another window and shows the filtered values instead of showing it within the parent subform.

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "3_Properties"

stLinkCriteria = "[Program_Name]=" & "'" & Me![Combo2] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Thanks

Answers


You can take advantage of link child and master fields to filter the subform without using any code. You can set the link master fields for your subform to the name of the combobox controls and the child fields to the relevant related columns (fields). Separate each entry with a semi-colon.

You can also set the record source of the subform at run time.

 sSQL = "SELECT BText FROM Table WHERE AText = '" & Me.MyCombo & "'"
 Me.MySubformControlName.Form.Recordsource = sSQL

Need Your Help

Evaluate a PHP file with the command line

php eclipse web-applications cordova

I am turning my PHP/MySQL/jQuery Mobile/Javascript webapp into a app thanks to Phonegap. I want to get rid of all PHP code (except while exchanging data with the server) to feed Phonegap with HTML ...

didSelectViewController method not being called (with storyboard)

ios ios5 uitabbarcontroller storyboard

I have 2 versions of a tabbed ios5 application, one created using a storyboard and one using xib files. The storyboard version does not call the UITabBarControllerDelegate method didSelectViewCont...